STXXL  1.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
error_handling.h File Reference
#include <sstream>
#include <cerrno>
#include <cstring>
#include <stxxl/bits/namespace.h>
#include <stxxl/bits/common/exceptions.h>
#include <stxxl/bits/config.h>

Go to the source code of this file.

Namespaces

 stxxl
 STXXL library namespace
 

Macros

#define STXXL_CHECK_PTHREAD_CALL(expr)
 Checks pthread call, if return != 0, throws stxxl::resource_error with "Error in [function] : [pthread_expr] : [errno message]. More...
 
#define STXXL_PRETTY_FUNCTION_NAME   __PRETTY_FUNCTION__
 
#define STXXL_THROW(exception_type, error_message)
 Throws exception_type with "Error in [function] : [error_message]". More...
 
#define STXXL_THROW2(exception_type, location, error_message)
 Throws exception_type with "Error in [location] : [error_message]". More...
 
#define STXXL_THROW_EQ_0(expr, exception_type, error_message)   STXXL_THROW_IF((expr) == 0, exception_type, error_message)
 Throws exception_type if (expr == 0) with "Error in [function] : [error_message]". More...
 
#define STXXL_THROW_ERRNO(exception_type, error_message)   STXXL_THROW_ERRNO2(exception_type, error_message, errno)
 Throws exception_type with "Error in [function] : [error_message] : [errno message]". More...
 
#define STXXL_THROW_ERRNO2(exception_type, error_message, errno_value)
 Throws exception_type with "Error in [function] : [error_message] : [errno_value message]". More...
 
#define STXXL_THROW_ERRNO_EQ_0(expr, exception_type, error_message)   STXXL_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 STXXL_THROW_ERRNO_IF(expr, exception_type, error_message)
 Throws exception_type if (expr) with "Error in [function] : [error_message] : [errno message]". More...
 
#define STXXL_THROW_ERRNO_LT_0(expr, exception_type, error_message)   STXXL_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 STXXL_THROW_ERRNO_NE_0(expr, exception_type, error_message)   STXXL_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 STXXL_THROW_IF(expr, exception_type, error_message)
 Throws exception_type if (expr) with "Error in [function] : [error_message]". More...
 
#define STXXL_THROW_INVALID_ARGUMENT(error_message)
 Throws std::invalid_argument with "Error in [function] : [error_message]". More...
 
#define STXXL_THROW_LT_0(expr, exception_type, error_message)   STXXL_THROW_IF((expr) < 0, exception_type, error_message)
 Throws exception_type if (expr < 0) with "Error in [function] : [error_message]". More...
 
#define STXXL_THROW_NE_0(expr, exception_type, error_message)   STXXL_THROW_IF((expr) != 0, exception_type, error_message)
 Throws exception_type if (expr != 0) with "Error in [function] : [error_message]". More...
 
#define STXXL_THROW_UNREACHABLE()
 Throws stxxl::unreachable with "Error in file [file], line [line] : this code should never be reachable". More...
 
#define STXXL_THROW_WIN_LASTERROR(exception_type, error_message)
 Throws exception_type with "Error in [function] : [error_message] : [formatted GetLastError()]". More...
 

Detailed Description

Macros for convenient error checking and reporting via exception.

Definition in file error_handling.h.

Macro Definition Documentation

#define STXXL_CHECK_PTHREAD_CALL (   expr)
Value:
do { \
int res = (expr); \
if (res != 0) { \
} \
} while (false)
#define STXXL_THROW_ERRNO2(exception_type, error_message, errno_value)
Throws exception_type with &quot;Error in [function] : [error_message] : [errno_value message]&quot;.

Checks pthread call, if return != 0, throws stxxl::resource_error with "Error in [function] : [pthread_expr] : [errno message].

Definition at line 122 of file error_handling.h.

Referenced by stxxl::condition_variable::condition_variable(), stxxl::mutex::lock(), stxxl::mutex::mutex(), stxxl::condition_variable::notify_all(), stxxl::condition_variable::notify_one(), stxxl::request_queue_impl_worker::start_thread(), stxxl::request_queue_impl_worker::stop_thread(), stxxl::mutex::unlock(), stxxl::condition_variable::wait(), stxxl::condition_variable::~condition_variable(), and stxxl::mutex::~mutex().

#define STXXL_PRETTY_FUNCTION_NAME   __PRETTY_FUNCTION__
#define STXXL_THROW (   exception_type,
  error_message 
)
Value:
STXXL_THROW2(exception_type, \
error_message)
#define STXXL_THROW2(exception_type, location, error_message)
Throws exception_type with &quot;Error in [location] : [error_message]&quot;.
#define STXXL_PRETTY_FUNCTION_NAME

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

Definition at line 48 of file error_handling.h.

Referenced by stxxl::create_file(), stxxl::disk_config::fileio_string(), stxxl::config::load_config_file(), stxxl::disk_config::parse_fileio(), and stxxl::disk_config::parse_line().

#define STXXL_THROW2 (   exception_type,
  location,
  error_message 
)
#define STXXL_THROW_EQ_0 (   expr,
  exception_type,
  error_message 
)    STXXL_THROW_IF((expr) == 0, exception_type, error_message)

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

Definition at line 90 of file error_handling.h.

#define STXXL_THROW_ERRNO2 (   exception_type,
  error_message,
  errno_value 
)
Value:
STXXL_THROW2(exception_type, \
error_message << " : " << strerror(errno_value))
#define STXXL_THROW2(exception_type, location, error_message)
Throws exception_type with &quot;Error in [location] : [error_message]&quot;.
#define STXXL_PRETTY_FUNCTION_NAME

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

Definition at line 54 of file error_handling.h.

Referenced by stxxl::mutex::~mutex().

#define STXXL_THROW_ERRNO_EQ_0 (   expr,
  exception_type,
  error_message 
)    STXXL_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 112 of file error_handling.h.

#define STXXL_THROW_ERRNO_IF (   expr,
  exception_type,
  error_message 
)
Value:
do { \
if (expr) { \
STXXL_THROW_ERRNO(exception_type, error_message); \
} \
} while (false)
#define STXXL_THROW_ERRNO(exception_type, error_message)
Throws exception_type with &quot;Error in [function] : [error_message] : [errno message]&quot;.

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

Definition at line 100 of file error_handling.h.

#define STXXL_THROW_ERRNO_LT_0 (   expr,
  exception_type,
  error_message 
)    STXXL_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 116 of file error_handling.h.

Referenced by stxxl::ufs_file_base::_set_size().

#define STXXL_THROW_ERRNO_NE_0 (   expr,
  exception_type,
  error_message 
)    STXXL_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 108 of file error_handling.h.

Referenced by stxxl::ufs_file_base::_after_open(), stxxl::ufs_file_base::_set_size(), and stxxl::mmap_file::serve().

#define STXXL_THROW_IF (   expr,
  exception_type,
  error_message 
)
Value:
do { \
if (expr) { \
STXXL_THROW(exception_type, error_message); \
} \
} while (false)
#define STXXL_THROW(exception_type, error_message)
Throws exception_type with &quot;Error in [function] : [error_message]&quot;.

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

Definition at line 78 of file error_handling.h.

#define STXXL_THROW_INVALID_ARGUMENT (   error_message)
Value:
STXXL_THROW2(std::invalid_argument, \
error_message)
#define STXXL_THROW2(exception_type, location, error_message)
Throws exception_type with &quot;Error in [location] : [error_message]&quot;.
#define STXXL_PRETTY_FUNCTION_NAME

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

Definition at line 64 of file error_handling.h.

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

#define STXXL_THROW_LT_0 (   expr,
  exception_type,
  error_message 
)    STXXL_THROW_IF((expr) < 0, exception_type, error_message)

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

Definition at line 94 of file error_handling.h.

#define STXXL_THROW_NE_0 (   expr,
  exception_type,
  error_message 
)    STXXL_THROW_IF((expr) != 0, exception_type, error_message)

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

Definition at line 86 of file error_handling.h.

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

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

Definition at line 70 of file error_handling.h.

Referenced by stxxl::stream::basic_runs_merger< typename runs_creator_type::sorted_runs_type, cmp_type, alloc_strategy_type >::fill_buffer_block(), stxxl::stream::basic_runs_merger< typename runs_creator_type::sorted_runs_type, cmp_type, alloc_strategy_type >::initialize(), and stxxl::sort_local::merge_runs().

#define STXXL_THROW_WIN_LASTERROR (   exception_type,
  error_message 
)
Value:
do { \
LPVOID lpMsgBuf; \
DWORD dw = GetLastError(); \
FormatMessage( \
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, \
NULL, dw, \
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), \
(LPTSTR)&lpMsgBuf, \
0, NULL); \
std::ostringstream msg; \
msg << "Error in " << STXXL_PRETTY_FUNCTION_NAME \
<< " : " << error_message \
<< " : error code " << dw << " : " << ((char*)lpMsgBuf); \
LocalFree(lpMsgBuf); \
throw exception_type(msg.str()); \
} while (false)
#define STXXL_PRETTY_FUNCTION_NAME

Throws exception_type with "Error in [function] : [error_message] : [formatted GetLastError()]".

Definition at line 135 of file error_handling.h.

Referenced by stxxl::ufs_file_base::_set_size(), stxxl::wfs_file_base::_size(), stxxl::wfs_file_base::close(), stxxl::config::load_default_config(), stxxl::wfs_file_base::lock(), stxxl::open_file_impl(), and stxxl::wfs_file_base::set_size().