Version: 16.3.1.167ea6ecff

Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
sal3d::Error Class Reference

Sal3d error management class of exceptions. More...

#include <Common.hpp>

Inheritance diagram for sal3d::Error:
sal3d::TransientError

Public Member Functions

 Error ()
 Default constructor, by default set to an error. More...
 
 Error (const struct sal3d_error &ep)
 Constructor that copies an error from a C sal3d_error struct.
 
 Error (int val, const char *format,...)
 Initialization from an error value and arbitrary text message.
 
 Error (int val)
 Initialization only from an error value, with zero text.
 
virtual const char * what () const throw ()
 Returns the error string, for std::exception polymorphism.
 
int fill_error (struct sal3d_error *es) const
 Copies the internal error data to a C sal3d_error struct. More...
 

Static Public Member Functions

static int set_no_error (struct sal3d_error *e)
 Set the sal3d_error data to no error. More...
 
static int set_error_msg (struct sal3d_error *e, int val, const char *format,...)
 Set the sal3d_error data to a value and arbitrary text. More...
 
static int set_unknown_error (struct sal3d_error *e)
 Set the sal3d_error data to the vague "Unknown error". More...
 

Public Attributes

sal3d_error e
 

Protected Member Functions

void text_from_ap (const char *format, va_list ap)
 

Detailed Description

Sal3d error management class of exceptions.

Wrapper for the C struct sal3d_error, that the SAL3D API uses in all the C library calls as a mean to convey complex information about errors that happened during the call.

This class, as the sal3d_error struct, does not involve memory allocation or deallocation. It can be quickly allocated to stack as an automatic variable, to allow calling any function that could fill it, and be thrown.

Most sal3d methods throw this class of exceptions. A programmer can catch them or directly std::exception and be able to report the text message to the user. Additionally, can use its Error::e.val integer to react to different situations.

Constructor & Destructor Documentation

sal3d::Error::Error ( )
inline

Default constructor, by default set to an error.

To help the programmer notice when forgetting to initialise it better. Passing it through a code that has to report success or error that fails to report success, will report error.

Member Function Documentation

int sal3d::Error::fill_error ( struct sal3d_error *  es) const
inline

Copies the internal error data to a C sal3d_error struct.

It only copies the error if 'es' is not null.

Returns
Returns the error int value
static int sal3d::Error::set_error_msg ( struct sal3d_error *  e,
int  val,
const char *  format,
  ... 
)
inlinestatic

Set the sal3d_error data to a value and arbitrary text.

To be used as exit point of C functions that have to also report the success to a sal3d_error structure.

It only fills the structure if the pointer is not null.

Returns
It returns the val passed as argument
static int sal3d::Error::set_no_error ( struct sal3d_error *  e)
inlinestatic

Set the sal3d_error data to no error.

To be used as exit point of C functions that have to also report the success to a sal3d_error structure.

It only fills the structure if the pointer is not null.

Returns
It returns SAL3D_ERROR_OK.
static int sal3d::Error::set_unknown_error ( struct sal3d_error *  e)
inlinestatic

Set the sal3d_error data to the vague "Unknown error".

To be used as exit point of C functions that have to also report the success to a sal3d_error structure.

As it's easy to report a message more useful than this on error situation, we advice to use this only in cases where the source of error is hard to know, like a catch(...).

It only fills the structure if the pointer is not null.

Returns
It returns SAL3D_ERROR_UNKNOWN

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