Compute Library
 20.05
Error.h File Reference
#include <array>
#include <string>

Go to the source code of this file.

Data Structures

class  Status
 Status class. More...
 

Namespaces

 arm_compute
 Copyright (c) 2017-2020 ARM Limited.
 

Macros

#define ARM_COMPUTE_UNUSED(...)   ::arm_compute::ignore_unused(__VA_ARGS__)
 To avoid unused variables warnings. More...
 
#define ARM_COMPUTE_CREATE_ERROR(error_code, msg)   arm_compute::create_error_msg(error_code, __func__, __FILE__, __LINE__, msg)
 Creates an error with a given message. More...
 
#define ARM_COMPUTE_CREATE_ERROR_LOC(error_code, func, file, line, msg)   arm_compute::create_error_msg(error_code, func, file, line, msg)
 Creates an error on location with a given message. More...
 
#define ARM_COMPUTE_CREATE_ERROR_LOC_VAR(error_code, func, file, line, msg, ...)
 Creates an error on location with a given message. More...
 
#define ARM_COMPUTE_RETURN_ERROR_MSG(...)
 An error is returned with the given description. More...
 
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
 Checks if a status contains an error and returns it. More...
 
#define ARM_COMPUTE_THROW_ON_ERROR(error)   error.throw_if_error();
 Checks if an error value is valid if not throws an exception with the error. More...
 
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG_VAR(cond, msg, ...)
 If the condition is true, an error is returned. More...
 
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
 If the condition is true, an error is returned. More...
 
#define ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG_VAR(cond, func, file, line, msg, ...)
 If the condition is true, an error is thrown. More...
 
#define ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(cond, func, file, line, msg)
 If the condition is true, an error is thrown. More...
 
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)   ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, #cond)
 If the condition is true, an error is returned. More...
 
#define ARM_COMPUTE_RETURN_ERROR_ON_LOC(cond, func, file, line)   ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(cond, func, file, line, #cond)
 If the condition is true, an error is returned. More...
 
#define ARM_COMPUTE_THROW_ERROR(func, file, line, msg)
 Print the given message then throw an std::runtime_error. More...
 
#define ARM_COMPUTE_THROW_ERROR_VAR(func, file, line, msg, ...)
 Print the given message then throw an std::runtime_error. More...
 
#define ARM_COMPUTE_ERROR_VAR(msg, ...)   ARM_COMPUTE_THROW_ERROR_VAR(__func__, __FILE__, __LINE__, msg, __VA_ARGS__)
 Print the given message then throw an std::runtime_error. More...
 
#define ARM_COMPUTE_ERROR(msg)   ARM_COMPUTE_THROW_ERROR(__func__, __FILE__, __LINE__, msg)
 Print the given message then throw an std::runtime_error. More...
 
#define ARM_COMPUTE_ERROR_LOC_VAR(func, file, line, msg, ...)   ARM_COMPUTE_THROW_ERROR_VAR(func, file, line, msg, __VA_ARGS__)
 Print the given message then throw an std::runtime_error. More...
 
#define ARM_COMPUTE_ERROR_LOC(func, file, line, msg)   ARM_COMPUTE_THROW_ERROR(func, file, line, msg)
 Print the given message then throw an std::runtime_error. More...
 
#define ARM_COMPUTE_EXIT_ON_MSG(cond, msg)
 If the condition is true, the given message is printed and program exits. More...
 
#define ARM_COMPUTE_EXIT_ON_MSG_VAR(cond, msg, ...)
 If the condition is true, the given message is printed and program exits. More...
 
#define ARM_COMPUTE_ERROR_THROW_ON(status)
 
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
 
#define ARM_COMPUTE_ERROR_ON_MSG_VAR(cond, msg, ...)
 
#define ARM_COMPUTE_ERROR_ON_LOC_MSG(cond, func, file, line, ...)
 
#define ARM_COMPUTE_CONST_ON_ERROR(cond, val, msg)   val
 
#define ARM_COMPUTE_ERROR_ON(cond)   ARM_COMPUTE_ERROR_ON_MSG(cond, #cond)
 If the condition is true then an error message is printed and an exception thrown. More...
 
#define ARM_COMPUTE_ERROR_ON_LOC(cond, func, file, line)   ARM_COMPUTE_ERROR_ON_LOC_MSG(cond, func, file, line, "%s", #cond)
 If the condition is true then an error message is printed and an exception thrown. More...
 
#define ARM_COMPUTE_THROW(ex)   throw(ex)
 

Enumerations

enum  ErrorCode { OK, RUNTIME_ERROR, UNSUPPORTED_EXTENSION_USE }
 Available error codes. More...
 

Functions

template<typename... T>
void ignore_unused (T &&...)
 Ignores unused arguments. More...
 
Status create_error (ErrorCode error_code, std::string msg)
 Creates an error containing the error message. More...
 
Status create_error_msg (ErrorCode error_code, const char *func, const char *file, int line, const char *msg)
 Creates an error and the error message. More...
 
void throw_error (Status err)
 Throw an std::runtime_error. More...
 

Macro Definition Documentation

◆ ARM_COMPUTE_CONST_ON_ERROR

#define ARM_COMPUTE_CONST_ON_ERROR (   cond,
  val,
  msg 
)    val

Definition at line 459 of file Error.h.

◆ ARM_COMPUTE_CREATE_ERROR

#define ARM_COMPUTE_CREATE_ERROR (   error_code,
  msg 
)    arm_compute::create_error_msg(error_code, __func__, __FILE__, __LINE__, msg)

Creates an error with a given message.

Parameters
[in]error_codeError code.
[in]msgMessage to encapsulate.

Definition at line 159 of file Error.h.

◆ ARM_COMPUTE_CREATE_ERROR_LOC

#define ARM_COMPUTE_CREATE_ERROR_LOC (   error_code,
  func,
  file,
  line,
  msg 
)    arm_compute::create_error_msg(error_code, func, file, line, msg)

Creates an error on location with a given message.

Parameters
[in]error_codeError code.
[in]funcFunction in which the error occurred.
[in]fileFile in which the error occurred.
[in]lineLine in which the error occurred.
[in]msgMessage to display before aborting.

Definition at line 169 of file Error.h.

◆ ARM_COMPUTE_CREATE_ERROR_LOC_VAR

#define ARM_COMPUTE_CREATE_ERROR_LOC_VAR (   error_code,
  func,
  file,
  line,
  msg,
  ... 
)
Value:
do \
{ \
std::array<char, 512> out{ 0 }; \
int offset = snprintf(out.data(), out.size(), "in %s %s:%d: ", func, file, line); \
snprintf(out.data() + offset, out.size() - offset, msg, __VA_ARGS__); \
arm_compute::create_error(error_code, std::string(out.data())); \
} while(false)
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:510
Status create_error(ErrorCode error_code, std::string msg)
Creates an error containing the error message.
Definition: Error.cpp:34
int snprintf(char *s, std::size_t n, const char *fmt, Ts &&... args)
Loads the data from the given location, converts them to character string equivalents and writes the ...

Creates an error on location with a given message.

Accepts a message format and a variable list of arguments matching the format description.

Parameters
[in]error_codeError code.
[in]funcFunction in which the error occurred.
[in]fileFile in which the error occurred.
[in]lineLine in which the error occurred.
[in]msgError description message format.
[in]...List of arguments matching the format description.

Definition at line 181 of file Error.h.

◆ ARM_COMPUTE_ERROR

#define ARM_COMPUTE_ERROR (   msg)    ARM_COMPUTE_THROW_ERROR(__func__, __FILE__, __LINE__, msg)

Print the given message then throw an std::runtime_error.

Parameters
[in]msgMessage to display.

Definition at line 352 of file Error.h.

◆ ARM_COMPUTE_ERROR_LOC

#define ARM_COMPUTE_ERROR_LOC (   func,
  file,
  line,
  msg 
)    ARM_COMPUTE_THROW_ERROR(func, file, line, msg)

Print the given message then throw an std::runtime_error.

Parameters
[in]funcFunction in which the error occurred.
[in]fileFile in which the error occurred.
[in]lineLine in which the error occurred.
[in]msgMessage to display.

Definition at line 372 of file Error.h.

◆ ARM_COMPUTE_ERROR_LOC_VAR

#define ARM_COMPUTE_ERROR_LOC_VAR (   func,
  file,
  line,
  msg,
  ... 
)    ARM_COMPUTE_THROW_ERROR_VAR(func, file, line, msg, __VA_ARGS__)

Print the given message then throw an std::runtime_error.

Accepts a message format and a variable list of arguments matching the format description.

Parameters
[in]funcFunction in which the error occurred.
[in]fileFile in which the error occurred.
[in]lineLine in which the error occurred.
[in]msgError description message format.
[in]...List of arguments matching the format description.

Definition at line 363 of file Error.h.

◆ ARM_COMPUTE_ERROR_ON

#define ARM_COMPUTE_ERROR_ON (   cond)    ARM_COMPUTE_ERROR_ON_MSG(cond, #cond)

If the condition is true then an error message is printed and an exception thrown.

Parameters
[in]condCondition to evaluate.

Definition at line 466 of file Error.h.

◆ ARM_COMPUTE_ERROR_ON_LOC

#define ARM_COMPUTE_ERROR_ON_LOC (   cond,
  func,
  file,
  line 
)    ARM_COMPUTE_ERROR_ON_LOC_MSG(cond, func, file, line, "%s", #cond)

If the condition is true then an error message is printed and an exception thrown.

Parameters
[in]condCondition to evaluate.
[in]funcFunction in which the error occurred.
[in]fileFile in which the error occurred.
[in]lineLine in which the error occurred.

Definition at line 476 of file Error.h.

◆ ARM_COMPUTE_ERROR_ON_LOC_MSG

#define ARM_COMPUTE_ERROR_ON_LOC_MSG (   cond,
  func,
  file,
  line,
  ... 
)

Definition at line 458 of file Error.h.

◆ ARM_COMPUTE_ERROR_ON_MSG

#define ARM_COMPUTE_ERROR_ON_MSG (   cond,
  msg 
)

Definition at line 456 of file Error.h.

◆ ARM_COMPUTE_ERROR_ON_MSG_VAR

#define ARM_COMPUTE_ERROR_ON_MSG_VAR (   cond,
  msg,
  ... 
)

Definition at line 457 of file Error.h.

◆ ARM_COMPUTE_ERROR_THROW_ON

#define ARM_COMPUTE_ERROR_THROW_ON (   status)

Definition at line 455 of file Error.h.

◆ ARM_COMPUTE_ERROR_VAR

#define ARM_COMPUTE_ERROR_VAR (   msg,
  ... 
)    ARM_COMPUTE_THROW_ERROR_VAR(__func__, __FILE__, __LINE__, msg, __VA_ARGS__)

Print the given message then throw an std::runtime_error.

Accepts a message format and a variable list of arguments matching the format description.

Parameters
[in]msgError description message format.
[in]...List of arguments matching the format description.

Definition at line 346 of file Error.h.

◆ ARM_COMPUTE_EXIT_ON_MSG

#define ARM_COMPUTE_EXIT_ON_MSG (   cond,
  msg 
)
Value:
do \
{ \
if(cond) \
{ \
ARM_COMPUTE_ERROR(msg); \
} \
} while(false)

If the condition is true, the given message is printed and program exits.

Parameters
[in]condCondition to evaluate.
[in]msgMessage to display.

Definition at line 379 of file Error.h.

◆ ARM_COMPUTE_EXIT_ON_MSG_VAR

#define ARM_COMPUTE_EXIT_ON_MSG_VAR (   cond,
  msg,
  ... 
)
Value:
do \
{ \
if(cond) \
{ \
ARM_COMPUTE_ERROR_VAR(msg, __VA_ARGS__); \
} \
} while(false)

If the condition is true, the given message is printed and program exits.

Accepts a message format and a variable list of arguments matching the format description.

Parameters
[in]condCondition to evaluate.
[in]msgError description message format.
[in]...List of arguments matching the format description.

Definition at line 395 of file Error.h.

◆ ARM_COMPUTE_RETURN_ERROR_MSG

#define ARM_COMPUTE_RETURN_ERROR_MSG (   ...)
Value:
do \
{ \
} while(false)
#define ARM_COMPUTE_CREATE_ERROR(error_code, msg)
Creates an error with a given message.
Definition: Error.h:159

An error is returned with the given description.

Parameters
[in]...Error description message.

Definition at line 194 of file Error.h.

◆ ARM_COMPUTE_RETURN_ERROR_ON

#define ARM_COMPUTE_RETURN_ERROR_ON (   cond)    ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, #cond)

If the condition is true, an error is returned.

Parameters
[in]condCondition to evaluate

Definition at line 296 of file Error.h.

◆ ARM_COMPUTE_RETURN_ERROR_ON_LOC

#define ARM_COMPUTE_RETURN_ERROR_ON_LOC (   cond,
  func,
  file,
  line 
)    ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(cond, func, file, line, #cond)

If the condition is true, an error is returned.

Parameters
[in]condCondition to evaluate.
[in]funcFunction in which the error occurred.
[in]fileFile in which the error occurred.
[in]lineLine in which the error occurred.

Definition at line 306 of file Error.h.

◆ ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG

#define ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG (   cond,
  func,
  file,
  line,
  msg 
)
Value:
do \
{ \
if(cond) \
{ \
return arm_compute::create_error_msg(ErrorCode::RUNTIME_ERROR, func, file, line, msg); \
} \
} while(false)
Status create_error_msg(ErrorCode error_code, const char *func, const char *file, int line, const char *msg)
Creates an error and the error message.
Definition: Error.cpp:39

If the condition is true, an error is thrown.

Parameters
[in]condCondition to evaluate.
[in]funcFunction in which the error occurred.
[in]fileFile in which the error occurred.
[in]lineLine in which the error occurred.
[in]msgMessage to display.

Definition at line 283 of file Error.h.

◆ ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG_VAR

#define ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG_VAR (   cond,
  func,
  file,
  line,
  msg,
  ... 
)
Value:
do \
{ \
if(cond) \
{ \
std::array<char, 512> out{ 0 }; \
int offset = snprintf(out.data(), out.size(), "in %s %s:%d: ", func, file, line); \
snprintf(out.data() + offset, out.size() - offset, msg, __VA_ARGS__); \
return arm_compute::create_error(ErrorCode::RUNTIME_ERROR, std::string(out.data())); \
} \
} while(false)
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:510
Status create_error(ErrorCode error_code, std::string msg)
Creates an error containing the error message.
Definition: Error.cpp:34
int snprintf(char *s, std::size_t n, const char *fmt, Ts &&... args)
Loads the data from the given location, converts them to character string equivalents and writes the ...

If the condition is true, an error is thrown.

Accepts a message format and a variable list of arguments matching the format description.

Parameters
[in]condCondition to evaluate.
[in]funcFunction in which the error occurred.
[in]fileFile in which the error occurred.
[in]lineLine in which the error occurred.
[in]msgError description message format.
[in]...List of arguments matching the format description.

Definition at line 263 of file Error.h.

◆ ARM_COMPUTE_RETURN_ERROR_ON_MSG

#define ARM_COMPUTE_RETURN_ERROR_ON_MSG (   cond,
  msg 
)
Value:
do \
{ \
if(cond) \
{ \
return arm_compute::create_error_msg(arm_compute::ErrorCode::RUNTIME_ERROR, __func__, __FILE__, __LINE__, msg); \
} \
} while(false)
Status create_error_msg(ErrorCode error_code, const char *func, const char *file, int line, const char *msg)
Creates an error and the error message.
Definition: Error.cpp:39

If the condition is true, an error is returned.

Parameters
[in]condCondition to evaluate.
[in]msgError description message

Definition at line 244 of file Error.h.

◆ ARM_COMPUTE_RETURN_ERROR_ON_MSG_VAR

#define ARM_COMPUTE_RETURN_ERROR_ON_MSG_VAR (   cond,
  msg,
  ... 
)
Value:
do \
{ \
if(cond) \
{ \
std::array<char, 512> out{ 0 }; \
int offset = snprintf(out.data(), out.size(), "in %s %s:%d: ", __func__, __FILE__, __LINE__); \
snprintf(out.data() + offset, out.size() - offset, msg, __VA_ARGS__); \
} \
} while(false)
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:510
Status create_error(ErrorCode error_code, std::string msg)
Creates an error containing the error message.
Definition: Error.cpp:34
int snprintf(char *s, std::size_t n, const char *fmt, Ts &&... args)
Loads the data from the given location, converts them to character string equivalents and writes the ...

If the condition is true, an error is returned.

Accepts a message format and a variable list of arguments matching the format description.

Parameters
[in]condCondition to evaluate.
[in]msgError description message format.
[in]...List of arguments matching the format description.

Definition at line 227 of file Error.h.

◆ ARM_COMPUTE_RETURN_ON_ERROR

#define ARM_COMPUTE_RETURN_ON_ERROR (   status)
Value:
do \
{ \
if(!bool(status)) \
{ \
return status; \
} \
} while(false)

Checks if a status contains an error and returns it.

Parameters
[in]statusStatus value to check

Definition at line 204 of file Error.h.

◆ ARM_COMPUTE_THROW

#define ARM_COMPUTE_THROW (   ex)    throw(ex)

Definition at line 480 of file Error.h.

◆ ARM_COMPUTE_THROW_ERROR

#define ARM_COMPUTE_THROW_ERROR (   func,
  file,
  line,
  msg 
)
Value:
do \
{ \
} while(false)
Status create_error_msg(ErrorCode error_code, const char *func, const char *file, int line, const char *msg)
Creates an error and the error message.
Definition: Error.cpp:39
void throw_error(Status err)
Throw an std::runtime_error.
Definition: Error.cpp:46

Print the given message then throw an std::runtime_error.

Parameters
[in]funcFunction in which the error occurred.
[in]fileFile in which the error occurred.
[in]lineLine in which the error occurred.
[in]msgMessage to display.

Definition at line 316 of file Error.h.

◆ ARM_COMPUTE_THROW_ERROR_VAR

#define ARM_COMPUTE_THROW_ERROR_VAR (   func,
  file,
  line,
  msg,
  ... 
)
Value:
do \
{ \
std::array<char, 512> out{ 0 }; \
int offset = snprintf(out.data(), out.size(), "in %s %s:%d: ", func, file, line); \
snprintf(out.data() + offset, out.size() - offset, msg, __VA_ARGS__); \
} while(false)
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:510
Status class.
Definition: Error.h:52
void throw_error(Status err)
Throw an std::runtime_error.
Definition: Error.cpp:46
int snprintf(char *s, std::size_t n, const char *fmt, Ts &&... args)
Loads the data from the given location, converts them to character string equivalents and writes the ...

Print the given message then throw an std::runtime_error.

Accepts a message format and a variable list of arguments matching the format description.

Parameters
[in]funcFunction in which the error occurred.
[in]fileFile in which the error occurred.
[in]lineLine in which the error occurred.
[in]msgError description message format.
[in]...List of arguments matching the format description.

Definition at line 331 of file Error.h.

◆ ARM_COMPUTE_THROW_ON_ERROR

#define ARM_COMPUTE_THROW_ON_ERROR (   error)    error.throw_if_error();

Checks if an error value is valid if not throws an exception with the error.

Parameters
[in]errorError value to check.

Definition at line 217 of file Error.h.

◆ ARM_COMPUTE_UNUSED

#define ARM_COMPUTE_UNUSED (   ...)    ::arm_compute::ignore_unused(__VA_ARGS__)

To avoid unused variables warnings.

This is useful if for example a variable is only used in debug builds and generates a warning in release builds.

Parameters
[in]...Variables which are unused.

Definition at line 152 of file Error.h.