GetErrorDescription

Description

GetErrorDescription returns the description of an error identified by its identification number.

Syntax

int GetErrorDescription(const int inError, const wchar_t*& owszDescription);

Parameters

Input

inError: the identification number of the error returned in the description. The identification number is different from 0 and is returned when an error occurs in a function.

Note: Negative error number refers to an OpenCL error code. Refer to OpenCL documentation for further details.

Output

owszDescription: the description of the error identified by the identification number inError.

Return

(int): returns the identification number of the error if an error occurs or 0 if no error occurs.

Example

#define OPT_PLUGIN_NO_ERROR 0
#define OPT_PLUGIN_ERROR_OPENCL_ERROR 1
#define OPT_PLUGIN_ERROR_NO_ALGO 2
#define OPT_PLUGIN_ERROR_UNKNOWN_ALGO 3
#define OPT_PLUGIN_ERROR_INVALID_DATA 4
#define OPT_PLUGIN_ERROR_UNKNOWN_SECTION 5
#define OPT_PLUGIN_ERROR_UNKNOWN_PARAMETER 6
#define OPT_PLUGIN_ERROR_KERNEL_LOADING 7
#define OPT_PLUGIN_ERROR_UNKNOWN_ENV_VAR 8
#define OPT_PLUGIN_ERROR_WARPING_FILE_LOADING 9
#define OPT_PLUGIN_ERROR_MISSING_INPUT_PARAMETERS 10
#define OPT_PLUGIN_ERROR_ROTATION_DRIVER_HEIGHT 11
#define OPT_PLUGIN_ERROR_CPU_ALLOC 12
#define OPT_PLUGIN_ERROR_PLUGIN_NOT_INITIALIZED 13
#define OPT_PLUGIN_ERROR_UNKNOWN_ERROR 14

std::map<int, std::wstring> gmErrorDescription;

gmErrorDescription[OPT_PLUGIN_ERROR_OPENCL_ERROR] = L"OpenCL error";
gmErrorDescription[OPT_PLUGIN_ERROR_NO_ALGO] = L"No algorithm defined";
gmErrorDescription[OPT_PLUGIN_ERROR_UNKNOWN_ALGO] = L"Algo index out of bounds";
gmErrorDescription[OPT_PLUGIN_ERROR_INVALID_DATA] = L"Empty or inconsistent data";
gmErrorDescription[OPT_PLUGIN_ERROR_UNKNOWN_SECTION] = L"Section index out of bounds";
gmErrorDescription[OPT_PLUGIN_ERROR_UNKNOWN_PARAMETER] = L"Unknown parameter";
gmErrorDescription[OPT_PLUGIN_ERROR_KERNEL_LOADING] = L"Cannot load kernel file";
gmErrorDescription[OPT_PLUGIN_ERROR_UNKNOWN_ENV_VAR] = L"Environment variable to plugin path not found";
gmErrorDescription[OPT_PLUGIN_ERROR_WARPING_FILE_LOADING] = L"Cannot load warping file";
gmErrorDescription[OPT_PLUGIN_ERROR_MISSING_INPUT_PARAMETERS] = L"Missing one or several input parameters";
gmErrorDescription[OPT_PLUGIN_ERROR_ROTATION_DRIVER_HEIGHT] = L"Mirror rotation and driver's height values do not match warping file data";
gmErrorDescription[OPT_PLUGIN_ERROR_CPU_ALLOC] = L"Error allocating on CPU";
gmErrorDescription[OPT_PLUGIN_ERROR_PLUGIN_NOT_INITIALIZED] = L"Plugin is not initialized. Please call Init() before any API calls.";
gmErrorDescription[OPT_PLUGIN_ERROR_UNKNOWN_ERROR] = L"Unknown error";

OPT_HIW_API int GetErrorDescription(const int inError, const wchar_t*& owszDescription)
{
     if (inError==0)
return OPT_PLUGIN_NO_ERROR;
     
// Check if error code is not out of bounds
     if (inError > 1 && inError <= (int)gmErrorDescription.size())
     {
owszDescription = gmErrorDescription[inError].c_str();
return OPT_PLUGIN_NO_ERROR;
     }
     else
     {
owszDescription = clGetErrorString(inError);
return OPT_PLUGIN_NO_ERROR;
     }
}