diff options
Diffstat (limited to 'subversion/include/svn_error.h')
-rw-r--r-- | subversion/include/svn_error.h | 71 |
1 files changed, 67 insertions, 4 deletions
diff --git a/subversion/include/svn_error.h b/subversion/include/svn_error.h index 55d27d2..3a6e4c5 100644 --- a/subversion/include/svn_error.h +++ b/subversion/include/svn_error.h @@ -66,6 +66,36 @@ svn_strerror(apr_status_t statcode, apr_size_t bufsize); +/** + * Return the symbolic name of an error code. If the error code + * is in svn_error_codes.h, return the name of the macro as a string. + * If the error number is not recognised, return @c NULL. + * + * An error number may not be recognised because it was defined in a future + * version of Subversion (e.g., a 1.9.x server may transmit a defined-in-1.9.0 + * error number to a 1.8.x client). + * + * An error number may be recognised @em incorrectly if the @c apr_status_t + * value originates in another library (such as libserf) which also uses APR. + * (This is a theoretical concern only: the @c apr_err member of #svn_error_t + * should never contain a "foreign" @c apr_status_t value, and + * in any case Subversion and Serf use non-overlapping subsets of the + * @c APR_OS_START_USERERR range.) + * + * Support for error codes returned by APR itself (i.e., not in the + * @c APR_OS_START_USERERR range, as defined in apr_errno.h) may be implemented + * in the future. + * + * @note In rare cases, a single numeric code has more than one symbolic name. + * (For example, #SVN_ERR_WC_NOT_DIRECTORY and #SVN_ERR_WC_NOT_WORKING_COPY). + * In those cases, it is not guaranteed which symbolic name is returned. + * + * @since New in 1.8. + */ +const char * +svn_error_symbolic_name(apr_status_t statcode); + + /** If @a err has a custom error message, return that, otherwise * store the generic error string associated with @a err->apr_err into * @a buf (terminating with NULL) and return @a buf. @@ -210,7 +240,7 @@ void svn_error_clear(svn_error_t *error); -#if defined(SVN_DEBUG) +#if defined(SVN_ERR__TRACING) /** Set the error location for debug mode. */ void svn_error__locate(const char *file, @@ -315,9 +345,10 @@ svn_handle_warning(FILE *stream, * @since New in 1.7. */ #ifdef SVN_ERR__TRACING -#define SVN_ERR__TRACED "traced call" +svn_error_t * +svn_error__trace(const char *file, long line, svn_error_t *err); -#define svn_error_trace(expr) svn_error_quick_wrap((expr), SVN_ERR__TRACED) +#define svn_error_trace(expr) svn_error__trace(__FILE__, __LINE__, (expr)) #else #define svn_error_trace(expr) (expr) #endif @@ -408,7 +439,7 @@ svn_error_t *svn_error_purge_tracing(svn_error_t *err); err->apr_err == SVN_ERR_RA_NOT_LOCKED || \ err->apr_err == SVN_ERR_FS_LOCK_EXPIRED) -/** Evaluates to @c TRUE iff @a apr_err (of type #apr_status_t) is in the given +/** Evaluates to @c TRUE iff @a apr_err (of type apr_status_t) is in the given * @a category, which should be one of the @c SVN_ERR_*_CATEGORY_START * constants. * @@ -460,6 +491,31 @@ svn_error_t *svn_error_purge_tracing(svn_error_t *err); abort(); \ } while (1) +/** 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. + */ +#ifdef __clang_analyzer__ +#include <assert.h> +/* Just ignore ERR. If the assert triggers, it'll be our least concern. */ +#define SVN_ERR_ASSERT_E(expr, err) assert((expr)) +#else +#define SVN_ERR_ASSERT_E(expr, err) \ + do { \ + if (!(expr)) { \ + return svn_error_compose_create( \ + svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr), \ + (err)); \ + } \ + } while (0) +#endif + + /** Check that a condition is true: if not, report an error and possibly * terminate the program. * @@ -478,12 +534,19 @@ svn_error_t *svn_error_purge_tracing(svn_error_t *err); * evaluation of this expression is not compiled out in release-mode builds. * * @since New in 1.6. + * + * @see SVN_ERR_ASSERT_E() */ +#ifdef __clang_analyzer__ +#include <assert.h> +#define SVN_ERR_ASSERT(expr) assert((expr)) +#else #define SVN_ERR_ASSERT(expr) \ do { \ if (!(expr)) \ SVN_ERR(svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr)); \ } while (0) +#endif /** Similar to SVN_ERR_ASSERT(), but without the option of returning * an error to the calling function. |