thrust::system::system_error
Defined in thrust/system/system_error.h
- 
class system_error : public runtime_error
- The class - system_errordescribes an exception object used to report error conditions that have an associated- error_code. Such error conditions typically originate from the operating system or other low-level application program interfaces.- Thrust uses - system_errorto report the error codes returned from device backends such as the CUDA runtime.- The following code listing demonstrates how to catch a - system_errorto recover from an error.- #include <thrust/device_vector.h> #include <thrust/system.h> #include <thrust/sort.h> void terminate_gracefully() { // application-specific termination code here ... } int main() { try { thrust::device_vector<float> vec; thrust::sort(vec.begin(), vec.end()); } catch(thrust::system_error e) { std::cerr << "Error inside sort: " << e.what() << std::endl; terminate_gracefully(); } return 0; } - Note - If an error represents an out-of-memory condition, implementations are encouraged to throw an exception object of type - std::bad_allocrather than- system_error.- Public Functions - 
inline system_error(error_code ec, const std::string &what_arg)
- Constructs an object of class - system_error.
 - 
inline system_error(error_code ec, const char *what_arg)
- Constructs an object of class - system_error.
 - 
inline system_error(error_code ec)
- Constructs an object of class - system_error.
 - 
inline system_error(int ev, const error_category &ecat, const std::string &what_arg)
- Constructs an object of class - system_error.- Parameters
- ev – The error value used to create an - error_code.
- ecat – The - error_categoryused to create an- error_code.
- what_arg – A string to include in the result returned by - what().
 
- Post
- code() == error_code(ev, ecat).
- Post
- std::string(what()).find(what_arg) != string::npos.
 
 - 
inline system_error(int ev, const error_category &ecat, const char *what_arg)
- Constructs an object of class - system_error.- Parameters
- ev – The error value used to create an - error_code.
- ecat – The - error_categoryused to create an- error_code.
- what_arg – A string to include in the result returned by - what().
 
- Post
- code() == error_code(ev, ecat).
- Post
- std::string(what()).find(what_arg) != string::npos.
 
 - 
inline system_error(int ev, const error_category &ecat)
- Constructs an object of class - system_error.- Parameters
- ev – The error value used to create an - error_code.
- ecat – The - error_categoryused to create an- error_code.
 
- Post
- code() == error_code(ev, ecat).
 
 - 
inline virtual ~system_error() noexcept
- Destructor does not throw. 
 - 
inline const error_code &code() const noexcept
- Returns an object encoding the error. - Returns
- ecor- error_code(ev, ecat), from the constructor, as appropriate.
 
 
- 
inline system_error(error_code ec, const std::string &what_arg)