Subversion
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Functions
Malfunctions and assertions

Internal malfunctions and assertions. More...

Macros

#define SVN_ERR_MALFUNCTION()
 Report that an internal malfunction has occurred, and possibly terminate the program. More...
 
#define SVN_ERR_MALFUNCTION_NO_RETURN()
 Similar to SVN_ERR_MALFUNCTION(), but without the option of returning an error to the calling function. More...
 
#define SVN_ERR_ASSERT_E(expr, err)
 Like SVN_ERR_ASSERT(), but append ERR to the returned error chain. More...
 
#define SVN_ERR_ASSERT(expr)
 Check that a condition is true: if not, report an error and possibly terminate the program. More...
 
#define SVN_ERR_ASSERT_NO_RETURN(expr)
 Similar to SVN_ERR_ASSERT(), but without the option of returning an error to the calling function. More...
 
#define SVN__NOT_IMPLEMENTED()   return svn_error__malfunction(TRUE, __FILE__, __LINE__, "Not implemented.")
 Report a "Not implemented" malfunction. More...
 

Typedefs

typedef svn_error_t *(* svn_error_malfunction_handler_t )(svn_boolean_t can_return, const char *file, int line, const char *expr)
 A type of function that handles an assertion failure or other internal malfunction detected within the Subversion libraries. More...
 

Functions

svn_error_tsvn_error__malfunction (svn_boolean_t can_return, const char *file, int line, const char *expr)
 A helper function for the macros that report malfunctions. More...
 
svn_error_malfunction_handler_t svn_error_set_malfunction_handler (svn_error_malfunction_handler_t func)
 Cause subsequent malfunctions to be handled by func. More...
 
svn_error_malfunction_handler_t svn_error_get_malfunction_handler (void)
 Return the malfunction handler that is currently in effect. More...
 
svn_error_tsvn_error_raise_on_malfunction (svn_boolean_t can_return, const char *file, int line, const char *expr)
 Handle a malfunction by returning an error object that describes it. More...
 
svn_error_tsvn_error_abort_on_malfunction (svn_boolean_t can_return, const char *file, int line, const char *expr)
 Handle a malfunction by printing a message to stderr and aborting. More...
 

Detailed Description

Internal malfunctions and assertions.

Macro Definition Documentation

#define SVN__NOT_IMPLEMENTED ( )    return svn_error__malfunction(TRUE, __FILE__, __LINE__, "Not implemented.")

Report a "Not implemented" malfunction.

Internal use only.

Definition at line 605 of file svn_error.h.

#define SVN_ERR_ASSERT (   expr)
Value:
do { \
if (!(expr)) \
SVN_ERR(svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr)); \
} while (0)
#define TRUE
uhh...
Definition: svn_types.h:143
#define SVN_ERR(expr)
A statement macro for checking error values.
Definition: svn_error.h:353
svn_error_t * svn_error__malfunction(svn_boolean_t can_return, const char *file, int line, const char *expr)
A helper function for the macros that report malfunctions.

Check that a condition is true: if not, report an error and possibly terminate the program.

If the Boolean expression expr is true, do nothing. Otherwise, act as determined by the current "malfunction handler" which may have been specified by a call to svn_error_set_malfunction_handler() or else is the default handler as specified in that function's documentation. If the malfunction handler returns, then cause the function using this macro to return the error object that it generated.

Note
The intended use of this macro is to check a condition that cannot possibly be false unless there is a bug in the program.
The condition to be checked should not be computationally expensive if it is reached often, as, unlike traditional "assert" statements, the evaluation of this expression is not compiled out in release-mode builds.
Since
New in 1.6.
See Also
SVN_ERR_ASSERT_E()

Definition at line 582 of file svn_error.h.

#define SVN_ERR_ASSERT_E (   expr,
  err 
)
Value:
do { \
if (!(expr)) { \
svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr), \
(err)); \
} \
} while (0)
svn_error_t * svn_error_compose_create(svn_error_t *err1, svn_error_t *err2)
Compose two errors, returning the composition as a brand new error and consuming the original errors...
#define TRUE
uhh...
Definition: svn_types.h:143
svn_error_t * svn_error__malfunction(svn_boolean_t can_return, const char *file, int line, const char *expr)
A helper function for the macros that report malfunctions.

Like SVN_ERR_ASSERT(), but append ERR to the returned error chain.

If EXPR is false, return a malfunction error whose chain includes ERR. If EXPR is true, do nothing. (In particular, this does not clear ERR.)

Types: (svn_boolean_t expr, svn_error_t *err)

Since
New in 1.8.

Definition at line 546 of file svn_error.h.

#define SVN_ERR_ASSERT_NO_RETURN (   expr)
Value:
do { \
if (!(expr)) { \
svn_error__malfunction(FALSE, __FILE__, __LINE__, #expr); \
abort(); \
} \
} while (0)
#define FALSE
uhh...
Definition: svn_types.h:148
svn_error_t * svn_error__malfunction(svn_boolean_t can_return, const char *file, int line, const char *expr)
A helper function for the macros that report malfunctions.

Similar to SVN_ERR_ASSERT(), but without the option of returning an error to the calling function.

If possible you should use SVN_ERR_ASSERT() instead.

Since
New in 1.6.

Definition at line 596 of file svn_error.h.

#define SVN_ERR_MALFUNCTION ( )
Value:
do { \
TRUE, __FILE__, __LINE__, NULL)); \
} while (0)
#define TRUE
uhh...
Definition: svn_types.h:143
svn_error_t * svn_error__malfunction(svn_boolean_t can_return, const char *file, int line, const char *expr)
A helper function for the macros that report malfunctions.
#define svn_error_trace(expr)
A macro for wrapping an error in a source-location trace message.
Definition: svn_error.h:375

Report that an internal malfunction has occurred, and possibly terminate the program.

Act as determined by the current "malfunction handler" which may have been specified by a call to svn_error_set_malfunction_handler() or else is the default handler as specified in that function's documentation. If the malfunction handler returns, then cause the function using this macro to return the error object that it generated.

Note
The intended use of this macro is where execution reaches a point that cannot possibly be reached unless there is a bug in the program.
Since
New in 1.6.

Definition at line 513 of file svn_error.h.

#define SVN_ERR_MALFUNCTION_NO_RETURN ( )
Value:
do { \
svn_error__malfunction(FALSE, __FILE__, __LINE__, NULL); \
abort(); \
} while (1)
#define FALSE
uhh...
Definition: svn_types.h:148
svn_error_t * svn_error__malfunction(svn_boolean_t can_return, const char *file, int line, const char *expr)
A helper function for the macros that report malfunctions.

Similar to SVN_ERR_MALFUNCTION(), but without the option of returning an error to the calling function.

If possible you should use SVN_ERR_MALFUNCTION() instead.

Since
New in 1.6.

Definition at line 526 of file svn_error.h.

Typedef Documentation

typedef svn_error_t*(* svn_error_malfunction_handler_t)(svn_boolean_t can_return, const char *file, int line, const char *expr)

A type of function that handles an assertion failure or other internal malfunction detected within the Subversion libraries.

The error occurred in the source file file at line line, and was an assertion failure of the expression expr, or, if expr is null, an unconditional error.

If can_return is false a function of this type must never return.

If can_return is true a function of this type must do one of:

  • Return an error object describing the error, using an error code in the category SVN_ERR_MALFUNC_CATEGORY_START.
  • Never return.

The function may alter its behaviour according to compile-time and run-time and even interactive conditions.

See Also
SVN_ERROR_IN_CATEGORY()
Since
New in 1.6.

Definition at line 651 of file svn_error.h.

Function Documentation

svn_error_t* svn_error__malfunction ( svn_boolean_t  can_return,
const char *  file,
int  line,
const char *  expr 
)

A helper function for the macros that report malfunctions.

Handle a malfunction by calling the current "malfunction handler" which may have been specified by a call to svn_error_set_malfunction_handler() or else is the default handler as specified in that function's documentation.

Pass all of the parameters to the handler. The error occurred in the source file file at line line, and was an assertion failure of the expression expr, or, if expr is null, an unconditional error.

If can_return is true, the handler can return an error object that is returned by the caller. If can_return is false the method should never return. (The caller will call abort())

Since
New in 1.6.
svn_error_t* svn_error_abort_on_malfunction ( svn_boolean_t  can_return,
const char *  file,
int  line,
const char *  expr 
)

Handle a malfunction by printing a message to stderr and aborting.

This function implements svn_error_malfunction_handler_t.

Since
New in 1.6.
svn_error_malfunction_handler_t svn_error_get_malfunction_handler ( void  )

Return the malfunction handler that is currently in effect.

Since
New in 1.9.
svn_error_t* svn_error_raise_on_malfunction ( svn_boolean_t  can_return,
const char *  file,
int  line,
const char *  expr 
)

Handle a malfunction by returning an error object that describes it.

When can_return is false, abort()

This function implements svn_error_malfunction_handler_t.

Since
New in 1.6.
svn_error_malfunction_handler_t svn_error_set_malfunction_handler ( svn_error_malfunction_handler_t  func)

Cause subsequent malfunctions to be handled by func.

Return the handler that was previously in effect.

func may not be null.

Note
The default handler is svn_error_abort_on_malfunction().
This function must be called in a single-threaded context.
Since
New in 1.6.