w_rc.h File Reference


Detailed Description

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 Documentation

#define RC (  )     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.

Examples:
create_rec.cpp, log_exceed.cpp, sort_stream.cpp, and vtable_example.cpp.

Definition at line 506 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,
 )     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.

Examples:
log_exceed.cpp.

Definition at line 517 of file w_rc.h.

#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.

Examples:
create_rec.cpp, init_config_options.cpp, log_exceed.cpp, sort_stream.cpp, and vtable_example.cpp.

Definition at line 527 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,
 )     ((condition) ? RC(e) : RCOK)

Return error e if condition is false.

Create a return code that indicates an error iff the condition is false, otherwise return with no-error indication.

Definition at line 535 of file w_rc.h.

#define W_EXPECT ( rc   )     rc

Give the compiler a hint that we expect to take the branch.

This macro is meaningful only with the GNU C++ compiler.

Definition at line 573 of file w_rc.h.

#define W_EXPECT_NOT ( rc   )     rc

Give the compiler a hint that we expect not to take the branch.

This macro is meaningful only with the GNU C++ compiler.

Definition at line 579 of file w_rc.h.

#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 591 of file w_rc.h.

Referenced by latch_t::upgrade_if_not_block().

#define RC_PUSH ( rc,
 )     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)

Definition at line 605 of file w_rc.h.

#define RC_APPEND_MSG ( rc,
 ) 

Value:

do {                            \
    w_ostrstream os;                    \
    os  m << ends;                    \
    rc->append_more_info_msg(os.c_str());        \
} while (0)
Augment stack trace with more arbitrary string information.

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)

Definition at line 618 of file w_rc.h.

#define W_EDO (  ) 

Value:

do {                            \
    w_rc_t::errcode_t __e = (x);                    \
    if (W_EXPECT_NOT(__e)) return RC(__e);        \
} while (0)
Call a method or function x that returns a lightweight error code from a method that returns a w_rc_t.

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.

Definition at line 645 of file w_rc.h.

#define W_DO (  ) 

Value:

do {                            \
    w_rc_t __e = (x);                    \
    if (W_EXPECT_NOT(__e.is_error())) return RC_AUGMENT(__e);        \
} while (0)
Call a method or function x.

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.

Examples:
create_rec.cpp, init_config_options.cpp, log_exceed.cpp, sort_stream.cpp, and vtable_example.cpp.

Definition at line 660 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,
 ) 

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)
Call a method or function x.

Like W_DO, but any error returned contains the additional information message m.

Definition at line 672 of file w_rc.h.

#define W_DO_GOTO ( rc,
 ) 

Value:

do {                            \
    (rc) = (x);    \
    if (W_EXPECT_NOT(rc.is_error())) { \
        RC_AUGMENT(rc);              \
        goto failure;    \
    } \
} while (0)
Idiom for unusual error-handling before returning.

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:

Note:
: the label failure must exist in the the calling function, and the argument rc must have been declared in the calling scope. Presumably the argument rc is declared in the scope of failure: as well, so that it can process the error.

Definition at line 702 of file w_rc.h.

#define W_DO_PUSH ( x,
 ) 

Value:

do {                            \
    w_rc_t __e = (x);                    \
    if (W_EXPECT_NOT(__e.is_error()))  { return RC_PUSH(__e, e); }    \
} while (0)
Call a function or method x, if error, push error code e on the stack and return.

This macro is like W_DO(x), but it adds an error code e to the stack trace before returning.

Definition at line 717 of file w_rc.h.

#define W_DO_PUSH_MSG ( x,
e,
 ) 

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)
Call a function or method x, if error, push error code e on the stack and return.

This macro is like W_DO_PUSH(x, e), but it adds an additional information message m to the stack trace before returning.

Definition at line 730 of file w_rc.h.

#define W_COERCE (  ) 

Value:

do {                            \
    w_rc_t __e = (x);                    \
    if (W_EXPECT_NOT(__e.is_error()))  {                \
    RC_AUGMENT(__e);                \
    __e.fatal();                    \
    }                            \
} while (0)
Call a function or method x, fail catastrophically if error is returned.

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.

Examples:
create_rec.cpp, log_exceed.cpp, sort_stream.cpp, startstop.cpp, and vtable_example.cpp.

Definition at line 759 of file w_rc.h.

Referenced by devid_t::devid_t(), sthread_init_t::do_init(), and sthread_init_t::~sthread_init_t().


Generated on Wed Jul 7 17:22:32 2010 for Shore Storage Manager by  doxygen 1.4.7