Subversion 1.6.16
Defines | Typedefs | Functions

svn_error.h File Reference

Common exception handling for Subversion. More...

#include <apr.h>
#include <apr_errno.h>
#include <apr_pools.h>
#include <apr_want.h>
#include "svn_types.h"
#include "svn_error_codes.h"

Go to the source code of this file.

Defines

#define SVN_NO_ERROR   0
 the best kind of (svn_error_t *) !
#define svn_error_create   (svn_error__locate(__FILE__,__LINE__), (svn_error_create))
 Wrapper macro to collect file and line information.
#define svn_error_createf   (svn_error__locate(__FILE__,__LINE__), (svn_error_createf))
 Wrapper macro to collect file and line information.
#define svn_error_wrap_apr   (svn_error__locate(__FILE__,__LINE__), (svn_error_wrap_apr))
 Wrapper macro to collect file and line information.
#define svn_error_quick_wrap   (svn_error__locate(__FILE__,__LINE__), (svn_error_quick_wrap))
 Wrapper macro to collect file and line information.
#define SVN_ERR(expr)
 A statement macro for checking error values.
#define SVN_ERR_W(expr, wrap_msg)
 A statement macro, very similar to SVN_ERR.
#define SVN_INT_ERR(expr)
 A statement macro, similar to SVN_ERR, but returns an integer.
#define SVN_ERR_IS_LOCK_ERROR(err)
 Return TRUE if err is an error specifically related to locking a path in the repository, FALSE otherwise.
#define SVN_ERR_IS_UNLOCK_ERROR(err)
 Return TRUE if err is an error specifically related to unlocking a path in the repository, FALSE otherwise.
#define SVN_ERR_MALFUNCTION()
 Report that an internal malfunction has occurred, and possibly terminate the program.
#define SVN_ERR_MALFUNCTION_NO_RETURN()
 Similar to SVN_ERR_MALFUNCTION(), but without the option of returning an error to the calling function.
#define SVN_ERR_ASSERT(expr)
 Check that a condition is true: if not, report an error and possibly terminate the program.
#define SVN_ERR_ASSERT_NO_RETURN(expr)
 Similar to SVN_ERR_ASSERT(), but without the option of returning an error to the calling function.

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.

Functions

void svn_error__locate (const char *file, long line)
 Set the error location for debug mode.
char * svn_strerror (apr_status_t statcode, char *buf, apr_size_t bufsize)
 Put an English description of statcode into buf and return buf, NULL-terminated.
const char * svn_err_best_message (svn_error_t *err, char *buf, apr_size_t bufsize)
 If err has a custom error message, return that, otherwise store the generic error string associated with err->apr_err into buf (terminating with NULL) and return buf.
svn_error_tsvn_error_create (apr_status_t apr_err, svn_error_t *child, const char *message)
 Create a nested exception structure.
svn_error_tsvn_error_createf (apr_status_t apr_err, svn_error_t *child, const char *fmt,...)
 Create an error structure with the given apr_err and child, with a printf-style error message produced by passing fmt, using apr_psprintf().
svn_error_tsvn_error_wrap_apr (apr_status_t status, const char *fmt,...)
 Wrap a status from an APR function.
svn_error_tsvn_error_quick_wrap (svn_error_t *child, const char *new_msg)
 A quick n' easy way to create a wrapped exception with your own message, before throwing it up the stack.
svn_error_tsvn_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.
void svn_error_compose (svn_error_t *chain, svn_error_t *new_err)
 Add new_err to the end of chain's chain of errors.
svn_error_tsvn_error_root_cause (svn_error_t *err)
 Return the root cause of err by finding the last error in its chain (e.g.
svn_error_tsvn_error_dup (svn_error_t *err)
 Create a new error that is a deep copy of err and return it.
void svn_error_clear (svn_error_t *error)
 Free the memory used by error, as well as all ancestors and descendants of error.
void svn_handle_error2 (svn_error_t *error, FILE *stream, svn_boolean_t fatal, const char *prefix)
 Very basic default error handler: print out error stack error to the stdio stream stream, with each error prefixed by prefix; quit and clear error iff the fatal flag is set.
void svn_handle_error (svn_error_t *error, FILE *stream, svn_boolean_t fatal)
 Like svn_handle_error2() but with prefix set to "svn: ".
void svn_handle_warning2 (FILE *stream, svn_error_t *error, const char *prefix)
 Very basic default warning handler: print out the error error to the stdio stream stream, prefixed by prefix.
void svn_handle_warning (FILE *stream, svn_error_t *error)
 Like svn_handle_warning2() but with prefix set to "svn: ".
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.
svn_error_malfunction_handler_t svn_error_set_malfunction_handler (svn_error_malfunction_handler_t func)
 Cause subsequent malfunctions to be handled by func.
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.
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.

Detailed Description

Common exception handling for Subversion.

Definition in file svn_error.h.


Define Documentation

#define SVN_ERR_ASSERT (   expr)
Value:
do {                                                                  \
    if (!(expr))                                                        \
      SVN_ERR(svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr)); \
  } while (0)

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.

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

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 402 of file svn_error.h.

#define SVN_ERR_IS_LOCK_ERROR (   err)
Value:
(err->apr_err == SVN_ERR_FS_PATH_ALREADY_LOCKED ||        \
   err->apr_err == SVN_ERR_FS_OUT_OF_DATE)                  \

Return TRUE if err is an error specifically related to locking a path in the repository, FALSE otherwise.

SVN_ERR_FS_OUT_OF_DATE is in here because it's a non-fatal error that can be thrown when attempting to lock an item.

Since:
New in 1.2.

Definition at line 320 of file svn_error.h.

#define SVN_ERR_IS_UNLOCK_ERROR (   err)
Value:
(err->apr_err == SVN_ERR_FS_PATH_NOT_LOCKED ||            \
   err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN ||             \
   err->apr_err == SVN_ERR_FS_LOCK_OWNER_MISMATCH ||        \
   err->apr_err == SVN_ERR_FS_NO_SUCH_LOCK ||               \
   err->apr_err == SVN_ERR_RA_NOT_LOCKED ||                 \
   err->apr_err == SVN_ERR_FS_LOCK_EXPIRED)

Return TRUE if err is an error specifically related to unlocking a path in the repository, FALSE otherwise.

Since:
New in 1.2.

Definition at line 330 of file svn_error.h.

#define SVN_ERR_MALFUNCTION ( )
Value:
do {                                                             \
    return svn_error__malfunction(TRUE, __FILE__, __LINE__, NULL); \
  } while (0)

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 352 of file svn_error.h.

#define SVN_ERR_MALFUNCTION_NO_RETURN ( )
Value:
do {                                                       \
    svn_error__malfunction(FALSE, __FILE__, __LINE__, NULL); \
    abort();                                                 \
  } while (1)

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

Since:
New in 1.6.

Definition at line 452 of file svn_error.h.


Function Documentation

const char* svn_err_best_message ( svn_error_t err,
char *  buf,
apr_size_t  bufsize 
)

If err has a custom error message, return that, otherwise store the generic error string associated with err->apr_err into buf (terminating with NULL) and return buf.

Since:
New in 1.4.
Note:
buf and bufsize are provided in the interface so that this function is thread-safe and yet does no allocation.
void svn_error__locate ( const char *  file,
long  line 
)

Set the error location for debug mode.

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_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.
char* svn_strerror ( apr_status_t  statcode,
char *  buf,
apr_size_t  bufsize 
)

Put an English description of statcode into buf and return buf, NULL-terminated.

statcode is either an svn error or apr error.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines