# Error handling

## Error management

wreport defines its own exception hierarchy, rooted at `wreport::error`.

Each wreport exception has a numeric identification code:

enum wreport::ErrorCode

  C-style error codes used by exceptions.

  Values:

  enumerator WR_ERR_NONE

    No error.

  enumerator WR_ERR_NOTFOUND

    Item not found.

  enumerator WR_ERR_TYPE

    Wrong variable type.

  enumerator WR_ERR_ALLOC

    Cannot allocate memory.

  enumerator WR_ERR_ODBC

    ODBC error.

  enumerator WR_ERR_HANDLES

    Handle management error.

  enumerator WR_ERR_TOOLONG

    Buffer is too short to fit data.

  enumerator WR_ERR_SYSTEM

    Error reported by the system.

  enumerator WR_ERR_CONSISTENCY

    Consistency check failed.

  enumerator WR_ERR_PARSE

    Parse error.

  enumerator WR_ERR_WRITE

    Write error.

  enumerator WR_ERR_REGEX

    Regular expression error.

  enumerator WR_ERR_UNIMPLEMENTED

    Feature not implemented.

  enumerator WR_ERR_DOMAIN

    Value outside acceptable domain.

The exceptions are:

class error : public std::exception

  Base class for DB-All.e exceptions.

  Subclassed by wreport::errors::StringBase< WR_ERR_CONSISTENCY >, wreport::errors::StringBase< WR_ERR_DOMAIN >, wreport::errors::StringBase< WR_ERR_HANDLES >, wreport::errors::StringBase< WR_ERR_NOTFOUND >, wreport::errors::StringBase< WR_ERR_PARSE >, wreport::errors::StringBase< WR_ERR_REGEX >, wreport::errors::StringBase< WR_ERR_SYSTEM >, wreport::errors::StringBase< WR_ERR_TOOLONG >, wreport::errors::StringBase< WR_ERR_TYPE >, wreport::errors::StringBase< WR_ERR_UNIMPLEMENTED >, wreport::error_alloc, wreport::errors::StringBase< ERROR_CODE >

  Public Functions

  virtual ErrorCode code() const noexcept = 0

    Exception-specific error code.

    This is useful to map C++ exceptions to C or Fortran error codes

  virtual const char *what() const noexcept = 0

    Error message.

  Public Static Functions

  static const char *strerror(ErrorCode code)

    String description for an error code.

class error_alloc : public wreport::error

  Reports that memory allocation has failed.

class error_notfound : public wreport::errors::StringBase<WR_ERR_NOTFOUND>

  Reports that a search-like function could not find what was requested.

class error_type : public wreport::errors::StringBase<WR_ERR_TYPE>

  For functions handling data with multiple types, reports a mismatch between the type requested and the type found.

class error_handles : public wreport::errors::StringBase<WR_ERR_HANDLES>

  For functions working with handles, reports a problem with handling handles, such as impossibility to allocate a new one, or an invalid handle being passed to the function.

class error_toolong : public wreport::errors::StringBase<WR_ERR_TOOLONG>

  Report an error with a buffer being to short for the data it needs to fit.

class error_system : public wreport::errors::StringBase<WR_ERR_SYSTEM>

  Report a system error message.

  The message description will be looked up using the current value of errno.

class error_consistency : public wreport::errors::StringBase<WR_ERR_CONSISTENCY>

  Report an error when a consistency check failed.

class error_parse : public wreport::errors::StringBase<WR_ERR_PARSE>

  Report an error when parsing informations.

class error_regexp : public wreport::errors::StringBase<WR_ERR_REGEX>

  Report an error while handling regular expressions.

class error_unimplemented : public wreport::errors::StringBase<WR_ERR_UNIMPLEMENTED>

  Reports that a feature is still not implemented.

class error_domain : public wreport::errors::StringBase<WR_ERR_DOMAIN>

  Report that a parameter is outside the acceptable domain.