Throwing an exception must be thread-safe to avoid surprises w/ OpenMP.
| 35 | |
| 36 | // Throwing an exception must be thread-safe to avoid surprises w/ OpenMP. |
| 37 | class exception : public std::exception { |
| 38 | public: |
| 39 | explicit exception(const char* message_, bool include_call = RCPP_DEFAULT_INCLUDE_CALL) : // #nocov start |
| 40 | message(message_), |
| 41 | include_call_(include_call) { |
| 42 | record_stack_trace(); |
| 43 | } |
| 44 | exception(const char* message_, const char*, int, bool include_call = RCPP_DEFAULT_INCLUDE_CALL) : |
| 45 | message(message_), |
| 46 | include_call_(include_call) { |
| 47 | record_stack_trace(); |
| 48 | } |
| 49 | bool include_call() const { |
| 50 | return include_call_; |
| 51 | } |
| 52 | virtual ~exception() throw() {} |
| 53 | virtual const char* what() const throw() { |
| 54 | return message.c_str(); // #nocov end |
| 55 | } |
| 56 | inline void copy_stack_trace_to_r() const; |
| 57 | private: |
| 58 | std::string message; |
| 59 | bool include_call_; |
| 60 | std::vector<std::string> stack; |
| 61 | inline void record_stack_trace(); |
| 62 | }; |
| 63 | |
| 64 | // simple helper |
| 65 | static std::string toString(const int i) { // #nocov start |
no outgoing calls