thrust
Public Member Functions | List of all members
thrust::system::system_error Class Reference

The class system_error describes 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. More...

#include <thrust/system/system_error.h>

Inherits runtime_error.

Public Member Functions

 system_error (error_code ec, const std::string &what_arg)
 
 system_error (error_code ec, const char *what_arg)
 
 system_error (error_code ec)
 
 system_error (int ev, const error_category &ecat, const std::string &what_arg)
 
 system_error (int ev, const error_category &ecat, const char *what_arg)
 
 system_error (int ev, const error_category &ecat)
 
virtual ~system_error (void) throw ()
 
const error_codecode (void) const throw ()
 
const char * what (void) const throw ()
 

Detailed Description

The class system_error describes 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_error to report the error codes returned from device backends such as the CUDA runtime.

The following code listing demonstrates how to catch a system_error to recover from an error.

#include <thrust/system.h>
#include <thrust/sort.h>
void terminate_gracefully(void)
{
// application-specific termination code here
...
}
int main(void)
{
try
{
thrust::sort(vec.begin(), vec.end());
}
{
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_alloc rather than system_error.

The documentation for this class was generated from the following file: