Compute Library
 19.08
Error.h File Reference
#include <stdarg.h>
#include <string>

Go to the source code of this file.

Data Structures

class  Status
 Status class. More...
 

Namespaces

 arm_compute
 Copyright (c) 2017-2018 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, ...)   ::arm_compute::create_error(error_code, __func__, __FILE__, __LINE__, __VA_ARGS__)
 Creates an error with a given message. More...
 
#define ARM_COMPUTE_CREATE_ERROR_LOC(error_code, func, file, line, ...)   ::arm_compute::create_error(error_code, func, file, line, __VA_ARGS__)
 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(cond, ...)
 If the condition is true, an error is returned. More...
 
#define ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG(cond, func, file, line, ...)
 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_ERROR(...)   ::arm_compute::error(__func__, __FILE__, __LINE__, __VA_ARGS__)
 Print the given message then throw an std::runtime_error. More...
 
#define ARM_COMPUTE_ERROR_LOC(func, file, line, ...)   ::arm_compute::error(func, file, line, __VA_ARGS__)
 Print the given message then throw an std::runtime_error. More...
 
#define ARM_COMPUTE_EXIT_ON_MSG(cond, ...)
 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, ...)
 
#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, #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_va_list (ErrorCode error_code, const char *function, const char *file, const int line, const char *msg, va_list args)
 Creates an error containing the error message from variable argument list. More...
 
Status create_error (ErrorCode error_code, const char *function, const char *file, const int line, const char *msg,...)
 Creates an error containing the error message. More...
 
void error (const char *function, const char *file, const int line, const char *msg,...)
 Print an error message then 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 330 of file Error.h.

◆ ARM_COMPUTE_CREATE_ERROR

#define ARM_COMPUTE_CREATE_ERROR (   error_code,
  ... 
)    ::arm_compute::create_error(error_code, __func__, __FILE__, __LINE__, __VA_ARGS__)

Creates an error with a given message.

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

Definition at line 167 of file Error.h.

◆ ARM_COMPUTE_CREATE_ERROR_LOC

#define ARM_COMPUTE_CREATE_ERROR_LOC (   error_code,
  func,
  file,
  line,
  ... 
)    ::arm_compute::create_error(error_code, func, file, line, __VA_ARGS__)

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]...Message to display before aborting.

Definition at line 177 of file Error.h.

◆ ARM_COMPUTE_ERROR

#define ARM_COMPUTE_ERROR (   ...)    ::arm_compute::error(__func__, __FILE__, __LINE__, __VA_ARGS__)

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

Parameters
[in]...Message to display before aborting.

Definition at line 261 of file Error.h.

◆ ARM_COMPUTE_ERROR_LOC

#define ARM_COMPUTE_ERROR_LOC (   func,
  file,
  line,
  ... 
)    ::arm_compute::error(func, file, line, __VA_ARGS__)

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]...Message to display before aborting.

Definition at line 270 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 337 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, #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 347 of file Error.h.

◆ ARM_COMPUTE_ERROR_ON_LOC_MSG

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

Definition at line 329 of file Error.h.

◆ ARM_COMPUTE_ERROR_ON_MSG

#define ARM_COMPUTE_ERROR_ON_MSG (   cond,
  ... 
)

Definition at line 328 of file Error.h.

◆ ARM_COMPUTE_ERROR_THROW_ON

#define ARM_COMPUTE_ERROR_THROW_ON (   status)

Definition at line 327 of file Error.h.

◆ ARM_COMPUTE_EXIT_ON_MSG

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

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

Parameters
[in]condCondition to evaluate.
[in]...Message to print if cond is false.

Definition at line 277 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,...)
Creates an error with a given message.
Definition: Error.h:167

An error is returned with the given description.

Parameters
[in]...Error description message.

Definition at line 183 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 244 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 254 of file Error.h.

◆ ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG

#define ARM_COMPUTE_RETURN_ERROR_ON_LOC_MSG (   cond,
  func,
  file,
  line,
  ... 
)
Value:
do \
{ \
if(cond) \
{ \
return ARM_COMPUTE_CREATE_ERROR_LOC(arm_compute::ErrorCode::RUNTIME_ERROR, func, file, line, __VA_ARGS__); \
} \
} while(false)
#define ARM_COMPUTE_CREATE_ERROR_LOC(error_code, func, file, line,...)
Creates an error on location with a given message.
Definition: Error.h:177

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]...Error description message.

Definition at line 231 of file Error.h.

◆ ARM_COMPUTE_RETURN_ERROR_ON_MSG

#define ARM_COMPUTE_RETURN_ERROR_ON_MSG (   cond,
  ... 
)
Value:
do \
{ \
if(cond) \
{ \
} \
} while(false)
#define ARM_COMPUTE_CREATE_ERROR(error_code,...)
Creates an error with a given message.
Definition: Error.h:167

If the condition is true, an error is returned.

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

Definition at line 214 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 193 of file Error.h.

◆ ARM_COMPUTE_THROW

#define ARM_COMPUTE_THROW (   ex)    throw(ex)

Definition at line 351 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 206 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 160 of file Error.h.