Thrill  0.1
error_handling.hpp File Reference
#include <cerrno>
#include <cstring>
#include <sstream>
#include <foxxll/common/exceptions.hpp>
#include <foxxll/config.hpp>
+ Include dependency graph for error_handling.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 foxxll
 FOXXLL library namespace
 

Macros

#define FOXXLL_PRETTY_FUNCTION_NAME   __PRETTY_FUNCTION__
 
#define FOXXLL_THROW(exception_type, error_message)
 Throws exception_type with "Error in [function] : [error_message]". More...
 
#define FOXXLL_THROW2(exception_type, location, error_message)
 Throws exception_type with "Error in [location] : [error_message]". More...
 
#define FOXXLL_THROW_ERRNO(exception_type, error_message)   FOXXLL_THROW_ERRNO2(exception_type, error_message, errno)
 Throws exception_type with "Error in [function] : [error_message] : [errno message]". More...
 
#define FOXXLL_THROW_ERRNO2(exception_type, error_message, errno_value)
 Throws exception_type with "Error in [function] : [error_message] : [errno_value message]". More...
 
#define FOXXLL_THROW_ERRNO_IF(expr, exception_type, error_message)
 Throws exception_type if (expr) with "Error in [function] : [error_message] : [errno message]". More...
 
#define FOXXLL_THROW_ERRNO_NE_0(expr, exception_type, error_message)   FOXXLL_THROW_ERRNO_IF((expr) != 0, exception_type, error_message)
 Throws exception_type if (expr != 0) with "Error in [function] : [error_message] : [errno message]". More...
 
#define FOXXLL_THROW_IF(expr, exception_type, error_message)
 Throws exception_type if (expr) with "Error in [function] : [error_message]". More...
 
#define FOXXLL_THROW_INVALID_ARGUMENT(error_message)
 Throws std::invalid_argument with "Error in [function] : [error_message]". More...
 
#define FOXXLL_THROW_UNREACHABLE()
 Throws foxxll::unreachable with "Error in file [file], line [line] : this code should never be reachable". More...
 

Detailed Description

Macros for convenient error checking and reporting via exception.

Definition in file error_handling.hpp.

Macro Definition Documentation

◆ FOXXLL_PRETTY_FUNCTION_NAME

#define FOXXLL_PRETTY_FUNCTION_NAME   __PRETTY_FUNCTION__

Definition at line 33 of file error_handling.hpp.

◆ FOXXLL_THROW

#define FOXXLL_THROW (   exception_type,
  error_message 
)
Value:
exception_type, \
error_message \
)
#define FOXXLL_THROW2(exception_type, location, error_message)
Throws exception_type with "Error in [location] : [error_message]".
#define FOXXLL_PRETTY_FUNCTION_NAME

Throws exception_type with "Error in [function] : [error_message]".

Definition at line 47 of file error_handling.hpp.

Referenced by foxxll::create_file(), disk_config::fileio_string(), config::load_config_file(), disk_block_allocator::new_blocks(), disk_config::parse_fileio(), and disk_config::parse_line().

◆ FOXXLL_THROW2

#define FOXXLL_THROW2 (   exception_type,
  location,
  error_message 
)
Value:
do { \
std::ostringstream msg; \
msg << "Error in " << location << " : " << error_message; \
throw exception_type(msg.str()); \
} while (false)

Throws exception_type with "Error in [location] : [error_message]".

Definition at line 39 of file error_handling.hpp.

Referenced by disk_block_allocator::add_free_region().

◆ FOXXLL_THROW_ERRNO

#define FOXXLL_THROW_ERRNO (   exception_type,
  error_message 
)    FOXXLL_THROW_ERRNO2(exception_type, error_message, errno)

Throws exception_type with "Error in [function] : [error_message] : [errno message]".

Definition at line 63 of file error_handling.hpp.

Referenced by ufs_file_base::_size(), ufs_file_base::close(), fileperblock_file< base_file_type >::export_files(), ufs_file_base::lock(), syscall_file::serve(), ufs_file_base::ufs_file_base(), and ufs_file_base::unlink().

◆ FOXXLL_THROW_ERRNO2

#define FOXXLL_THROW_ERRNO2 (   exception_type,
  error_message,
  errno_value 
)
Value:
exception_type, \
error_message << " : " << strerror(errno_value) \
)
#define FOXXLL_THROW2(exception_type, location, error_message)
Throws exception_type with "Error in [location] : [error_message]".
#define FOXXLL_PRETTY_FUNCTION_NAME

Throws exception_type with "Error in [function] : [error_message] : [errno_value message]".

Definition at line 55 of file error_handling.hpp.

◆ FOXXLL_THROW_ERRNO_IF

#define FOXXLL_THROW_ERRNO_IF (   expr,
  exception_type,
  error_message 
)
Value:
do { \
if (expr) { \
FOXXLL_THROW_ERRNO(exception_type, error_message); \
} \
} while (false)

Throws exception_type if (expr) with "Error in [function] : [error_message] : [errno message]".

Definition at line 93 of file error_handling.hpp.

◆ FOXXLL_THROW_ERRNO_NE_0

#define FOXXLL_THROW_ERRNO_NE_0 (   expr,
  exception_type,
  error_message 
)    FOXXLL_THROW_ERRNO_IF((expr) != 0, exception_type, error_message)

Throws exception_type if (expr != 0) with "Error in [function] : [error_message] : [errno message]".

Definition at line 101 of file error_handling.hpp.

Referenced by ufs_file_base::_after_open(), and ufs_file_base::_set_size().

◆ FOXXLL_THROW_IF

#define FOXXLL_THROW_IF (   expr,
  exception_type,
  error_message 
)
Value:
do { \
if (expr) { \
FOXXLL_THROW(exception_type, error_message); \
} \
} while (false)

Throws exception_type if (expr) with "Error in [function] : [error_message]".

Definition at line 85 of file error_handling.hpp.

Referenced by ufs_file_base::_set_size(), file_stats_data::operator+(), and file_stats_data::operator-().

◆ FOXXLL_THROW_INVALID_ARGUMENT

#define FOXXLL_THROW_INVALID_ARGUMENT (   error_message)
Value:
std::invalid_argument, \
error_message \
)
#define FOXXLL_THROW2(exception_type, location, error_message)
Throws exception_type with "Error in [location] : [error_message]".
#define FOXXLL_PRETTY_FUNCTION_NAME

Throws std::invalid_argument with "Error in [function] : [error_message]".

Definition at line 67 of file error_handling.hpp.

Referenced by request_queue_impl_1q::add_request(), request_queue_impl_qwqr::add_request(), request_queue_impl_1q::cancel_request(), and request_queue_impl_qwqr::cancel_request().

◆ FOXXLL_THROW_UNREACHABLE

#define FOXXLL_THROW_UNREACHABLE ( )
Value:
"file " << __FILE__ << ", line " << __LINE__, \
"this code should never be reachable" \
)
#define FOXXLL_THROW2(exception_type, location, error_message)
Throws exception_type with "Error in [location] : [error_message]".

Throws foxxll::unreachable with "Error in file [file], line [line] : this code should never be reachable".

Definition at line 75 of file error_handling.hpp.