| Home | Libraries | People | FAQ | More

## Class opencl_error

boost::compute::opencl_error — A run-time OpenCL error.

## Synopsis

    // In header: <boost/compute/exception/opencl_error.hpp>

    class opencl_error : public std::exception {
    public:

      // public member functions
      explicit opencl_error(cl_int);
      ~opencl_error();
      cl_int error_code() const;
      std::string error_string() const;
      const char * what() const;

      // public static functions
      static std::string to_string(cl_int);
    };

## Description

The opencl_error class represents an error returned from an OpenCL function.

See Also: context_error

### `opencl_error` public member functions

1.     explicit opencl_error(cl_int error);

   Creates a new opencl_error exception object for `error`.

2.     ~opencl_error();

   Destroys the opencl_error object.

3.     cl_int error_code() const;

   Returns the numeric error code.

4.     std::string error_string() const;

   Returns a string description of the error.

5.     const char * what() const;

   Returns a C-string description of the error.

### `opencl_error` public static functions

1.     static std::string to_string(cl_int error);

   Static function which converts the numeric OpenCL error code `error` to a human-readable string.

   For example:

       std::cout << opencl_error::to_string(CL_INVALID_KERNEL_ARGS) << std::endl;

   Will print "Invalid Kernel Arguments".

   If the error code is unknown (e.g. not a valid OpenCL error), a string containing "Unknown OpenCL Error" along with the error number will be returned.