Definition in file w_rc.h.
Go to the source code of this file.
Classes | |
class | w_rc_t |
Return code for most functions and methods. More... | |
class | w_rc_i |
Iterator over w_error_t list : helper for w_rc_t. More... | |
Defines | |
#define | RC(e) w_rc_t(__FILE__, __LINE__, e) |
Normal error-case return. | |
#define | RC2(e, s) w_rc_t(__FILE__, __LINE__, e, s) |
Normal error-case return with sys_error. | |
#define | RCOK w_rc_t::rc_ok |
Normal return value for no-error case. | |
#define | MAKERC(condition, e) ((condition) ? RC(e) : RCOK) |
Return error e if condition is false. | |
#define | W_EXPECT(rc) rc |
Give the compiler a hint that we expect to take the branch. | |
#define | W_EXPECT_NOT(rc) rc |
Give the compiler a hint that we expect not to take the branch. | |
#define | RC_AUGMENT(rc) rc.add_trace_info(__FILE__, __LINE__) |
Augment stack trace. | |
#define | RC_PUSH(rc, e) rc.push(__FILE__, __LINE__, e) |
Augment stack trace with another error code. | |
#define | RC_APPEND_MSG(rc, m) |
Augment stack trace with more arbitrary string information. | |
#define | W_RETURN_RC_MSG(e, m) |
Retrun with a return code that contains the given error code and additional message. | |
#define | W_EDO(x) |
Call a method or function x that returns a lightweight error code from a method that returns a w_rc_t. | |
#define | W_DO(x) |
Call a method or function x. | |
#define | W_DO_MSG(x, m) |
Call a method or function x. | |
#define | W_DO_GOTO(rc, x) |
Idiom for unusual error-handling before returning. | |
#define | W_DO_PUSH(x, e) |
Call a function or method x, if error, push error code e on the stack and return. | |
#define | W_DO_PUSH_MSG(x, e, m) |
Call a function or method x, if error, push error code e on the stack and return. | |
#define | W_COERCE(x) |
Call a function or method x, fail catastrophically if error is returned. | |
#define | W_COERCE_MSG(x, m) |
Same as W_COERCE(x) but adds a string message before croaking. | |
#define | W_FATAL(e) W_COERCE(RC(e)) |
Croak with the error code e. | |
#define | W_FATAL_RC(rc) W_COERCE(rc) |
Croak with the return code rc. | |
#define | W_FATAL_MSG(e, m) W_COERCE_MSG(RC(e), m) |
Croak with the error code e and message m. | |
#define | W_IGNORE(x) ((void) x.is_error()) |
Invoke x and ignore its result. |
#define RC | ( | e | ) | w_rc_t(__FILE__, __LINE__, e) |
Normal error-case return.
Create a return code with the current file, line, and error code x. This is the normal way to return from a method or function.
Definition at line 551 of file w_rc.h.
Referenced by option_group_t::add_class_level(), option_group_t::add_option(), sthread_t::block(), option_group_t::check_required(), option_t::concatValue(), option_t::copyValue(), sthread_t::dump_stats(), sthread_t::fork(), sthread_t::join(), option_group_t::lookup(), option_group_t::lookup_by_class(), option_group_t::parse_command_line(), option_file_scan_t::scan(), option_stream_scan_t::scan(), option_group_t::set_value(), option_t::set_value_bool(), option_t::set_value_int4(), and option_t::set_value_int8().
#define RC2 | ( | e, | |||
s | ) | w_rc_t(__FILE__, __LINE__, e, s) |
Normal error-case return with sys_error.
Create a return code with the current file, line, and error code e, and system error number s. This is the normal way to return an error indication from a method or function that encountered a system error. The value s allows the user to convey an errno value in the return code.
#define RCOK w_rc_t::rc_ok |
Normal return value for no-error case.
Const return code that indicates no error. This is the normal way to return from a method or function.
Definition at line 572 of file w_rc.h.
Referenced by option_group_t::add_class_level(), option_group_t::add_option(), sthread_t::block(), option_t::concatValue(), option_t::copyValue(), sthread_t::fork(), option_stream_scan_t::scan(), sthread_t::set_priority(), option_group_t::set_value(), option_t::set_value(), option_t::set_value_bool(), option_t::set_value_charstr(), option_t::set_value_int4(), option_t::set_value_int8(), latch_t::upgrade_if_not_block(), and ss_m::vol_root_index().
#define MAKERC | ( | condition, | |||
e | ) | ((condition) ? RC(e) : RCOK) |
#define W_EXPECT | ( | rc | ) | rc |
#define W_EXPECT_NOT | ( | rc | ) | rc |
#define RC_AUGMENT | ( | rc | ) | rc.add_trace_info(__FILE__, __LINE__) |
Augment stack trace.
Add stack trace information (file, line) to a return code. This is the normal way to return from a method or function upon receiving an error from a method or function that it called. Used by W_DO(x), W_DO_MSG(x,m), W_DO_GOTO(rc,x), and W_COERCE(x)
Definition at line 643 of file w_rc.h.
Referenced by latch_t::upgrade_if_not_block().
#define RC_PUSH | ( | rc, | |||
e | ) | rc.push(__FILE__, __LINE__, e) |
Augment stack trace with another error code.
Add stack trace informatin (file, line, error) to a return code. This is to return from a method or function upon receiving an error from a method or function that it called, when a what you want to return to your caller is a different error code from that returned by the method just called. Used by W_DO_PUSH(x, e) and W_DO_PUSH_MSG(x,e, m)
#define RC_APPEND_MSG | ( | rc, | |||
m | ) |
Value:
do { \ w_ostrstream os; \ os m << ends; \ rc->append_more_info_msg(os.c_str()); \ } while (0)
Add a char string representing more information to a return code. Used by W_RETURN_RC_MSG(e, m), W_DO_MSG(x, m), W_DO_PUSH_MSG(x, m), and W_COERCE_MSG(x, m)
#define W_EDO | ( | x | ) |
Value:
do { \ w_rc_t::errcode_t __e = (x); \ if (W_EXPECT_NOT(__e)) return RC(__e); \ } while (0)
This macro is used deep in the storage manager to call a method or function that returns a (lightweight) error code rather than a w_rc_t. It checks the returned code for the error case, and if it finds an error, it creates a w_rc_t with the error code returned by the called function or method.
#define W_DO | ( | x | ) |
Value:
do { \ w_rc_t __e = (x); \ if (W_EXPECT_NOT(__e.is_error())) return RC_AUGMENT(__e); \ } while (0)
This macro is the normal idiom for calling a method or function. Most methods and functions return a w_rc_t. This macro calls x and checks its returned value. If an error is encountered, it immediately returns from the current function or method, augmenting the stack trace held by the return code.
Definition at line 713 of file w_rc.h.
Referenced by option_group_t::add_option(), option_group_t::set_value(), option_t::set_value(), option_t::set_value_bool(), option_t::set_value_charstr(), option_t::set_value_int4(), and option_t::set_value_int8().
#define W_DO_MSG | ( | x, | |||
m | ) |
Value:
do { \ w_rc_t __e = (x); \ if (W_EXPECT_NOT(__e.is_error())) { \ RC_AUGMENT(__e); \ RC_APPEND_MSG(__e, m); \ return __e; \ } \ } while (0)
Like W_DO, but any error returned contains the additional information message m.
#define W_DO_GOTO | ( | rc, | |||
x | ) |
Value:
do { \ (rc) = (x); \ if (W_EXPECT_NOT(rc.is_error())) { \ RC_AUGMENT(rc); \ goto failure; \ } \ } while (0)
This macro is used to process errors that require special handling before the calling function can return. It calls the method or function x, and if x returns an error, it transfers control to the label failure.
Like W_DO, but:
#define W_DO_PUSH | ( | x, | |||
e | ) |
Value:
do { \ w_rc_t __e = (x); \ if (W_EXPECT_NOT(__e.is_error())) { return RC_PUSH(__e, e); } \ } while (0)
This macro is like W_DO(x), but it adds an error code e to the stack trace before returning.
#define W_DO_PUSH_MSG | ( | x, | |||
e, | |||||
m | ) |
Value:
do { \ w_rc_t __e = (x); \ if (W_EXPECT_NOT(__e.is_error())) { \ RC_PUSH(__e, e); \ RC_APPEND_MSG(__e, m); \ return __e; \ } \ } while (0)
This macro is like W_DO_PUSH(x, e), but it adds an additional information message m to the stack trace before returning.
#define W_COERCE | ( | x | ) |
Value:
do { \ w_rc_t __e = (x); \ if (W_EXPECT_NOT(__e.is_error())) { \ RC_AUGMENT(__e); \ __e.fatal(); \ } \ } while (0)
This macro is like W_DO(x), but instead of returning in the error case, it fails catastrophically. It is used in cases such as these:
The call to __e.fatal() prints the stack trace and additional information associated with the w_rc_t before it croaks.
Definition at line 812 of file w_rc.h.
Referenced by devid_t::devid_t(), sthread_init_t::do_init(), and sthread_init_t::~sthread_init_t().