00001 /** 00002 * @copyright 00003 * ==================================================================== 00004 * Licensed to the Apache Software Foundation (ASF) under one 00005 * or more contributor license agreements. See the NOTICE file 00006 * distributed with this work for additional information 00007 * regarding copyright ownership. The ASF licenses this file 00008 * to you under the Apache License, Version 2.0 (the 00009 * "License"); you may not use this file except in compliance 00010 * with the License. You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, 00015 * software distributed under the License is distributed on an 00016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 00017 * KIND, either express or implied. See the License for the 00018 * specific language governing permissions and limitations 00019 * under the License. 00020 * ==================================================================== 00021 * @endcopyright 00022 * 00023 * @file svn_error.h 00024 * @brief Common exception handling for Subversion. 00025 */ 00026 00027 #ifndef SVN_ERROR_H 00028 #define SVN_ERROR_H 00029 00030 #include <apr.h> /* for apr_size_t */ 00031 #include <apr_errno.h> /* APR's error system */ 00032 #include <apr_pools.h> /* for apr_pool_t */ 00033 00034 #ifndef DOXYGEN_SHOULD_SKIP_THIS 00035 #define APR_WANT_STDIO 00036 #endif 00037 #include <apr_want.h> /* for FILE* */ 00038 00039 #include "svn_types.h" 00040 00041 #ifdef __cplusplus 00042 extern "C" { 00043 #endif /* __cplusplus */ 00044 00045 00046 /* For the Subversion developers, this #define turns on extended "stack 00047 traces" of any errors that get thrown. See the SVN_ERR() macro. */ 00048 #ifdef SVN_DEBUG 00049 #define SVN_ERR__TRACING 00050 #endif 00051 00052 00053 /** the best kind of (@c svn_error_t *) ! */ 00054 #define SVN_NO_ERROR 0 00055 00056 /* The actual error codes are kept in a separate file; see comments 00057 there for the reasons why. */ 00058 #include "svn_error_codes.h" 00059 00060 /** Put an English description of @a statcode into @a buf and return @a buf, 00061 * NULL-terminated. @a statcode is either an svn error or apr error. 00062 */ 00063 char * 00064 svn_strerror(apr_status_t statcode, 00065 char *buf, 00066 apr_size_t bufsize); 00067 00068 00069 /** 00070 * Return the symbolic name of an error code. If the error code 00071 * is in svn_error_codes.h, return the name of the macro as a string. 00072 * If the error number is not recognised, return @c NULL. 00073 * 00074 * An error number may not be recognised because it was defined in a future 00075 * version of Subversion (e.g., a 1.9.x server may transmit a defined-in-1.9.0 00076 * error number to a 1.8.x client). 00077 * 00078 * An error number may be recognised @em incorrectly if the @c apr_status_t 00079 * value originates in another library (such as libserf) which also uses APR. 00080 * (This is a theoretical concern only: the @c apr_err member of #svn_error_t 00081 * should never contain a "foreign" @c apr_status_t value, and 00082 * in any case Subversion and Serf use non-overlapping subsets of the 00083 * @c APR_OS_START_USERERR range.) 00084 * 00085 * Support for error codes returned by APR itself (i.e., not in the 00086 * @c APR_OS_START_USERERR range, as defined in apr_errno.h) may be implemented 00087 * in the future. 00088 * 00089 * @note In rare cases, a single numeric code has more than one symbolic name. 00090 * (For example, #SVN_ERR_WC_NOT_DIRECTORY and #SVN_ERR_WC_NOT_WORKING_COPY). 00091 * In those cases, it is not guaranteed which symbolic name is returned. 00092 * 00093 * @since New in 1.8. 00094 */ 00095 const char * 00096 svn_error_symbolic_name(apr_status_t statcode); 00097 00098 00099 /** If @a err has a custom error message, return that, otherwise 00100 * store the generic error string associated with @a err->apr_err into 00101 * @a buf (terminating with NULL) and return @a buf. 00102 * 00103 * @since New in 1.4. 00104 * 00105 * @note @a buf and @a bufsize are provided in the interface so that 00106 * this function is thread-safe and yet does no allocation. 00107 */ 00108 const char *svn_err_best_message(const svn_error_t *err, 00109 char *buf, 00110 apr_size_t bufsize); 00111 00112 00113 00114 /** SVN error creation and destruction. 00115 * 00116 * @defgroup svn_error_error_creation_destroy Error creation and destruction 00117 * @{ 00118 */ 00119 00120 /** Create a nested exception structure. 00121 * 00122 * Input: an APR or SVN custom error code, 00123 * a "child" error to wrap, 00124 * a specific message 00125 * 00126 * Returns: a new error structure (containing the old one). 00127 * 00128 * @note Errors are always allocated in a subpool of the global pool, 00129 * since an error's lifetime is generally not related to the 00130 * lifetime of any convenient pool. Errors must be freed 00131 * with svn_error_clear(). The specific message should be @c NULL 00132 * if there is nothing to add to the general message associated 00133 * with the error code. 00134 * 00135 * If creating the "bottommost" error in a chain, pass @c NULL for 00136 * the child argument. 00137 */ 00138 svn_error_t * 00139 svn_error_create(apr_status_t apr_err, 00140 svn_error_t *child, 00141 const char *message); 00142 00143 /** Create an error structure with the given @a apr_err and @a child, 00144 * with a printf-style error message produced by passing @a fmt, using 00145 * apr_psprintf(). 00146 */ 00147 svn_error_t * 00148 svn_error_createf(apr_status_t apr_err, 00149 svn_error_t *child, 00150 const char *fmt, 00151 ...) 00152 __attribute__ ((format(printf, 3, 4))); 00153 00154 /** Wrap a @a status from an APR function. If @a fmt is NULL, this is 00155 * equivalent to svn_error_create(status,NULL,NULL). Otherwise, 00156 * the error message is constructed by formatting @a fmt and the 00157 * following arguments according to apr_psprintf(), and then 00158 * appending ": " and the error message corresponding to @a status. 00159 * (If UTF-8 translation of the APR error message fails, the ": " and 00160 * APR error are not appended to the error message.) 00161 */ 00162 svn_error_t * 00163 svn_error_wrap_apr(apr_status_t status, 00164 const char *fmt, 00165 ...) 00166 __attribute__((format(printf, 2, 3))); 00167 00168 /** If @a child is SVN_NO_ERROR, return SVN_NO_ERROR. 00169 * Else, prepend a new error to the error chain of @a child. The new error 00170 * uses @a new_msg as error message but all other error attributes (such 00171 * as the error code) are copied from @a child. 00172 */ 00173 svn_error_t * 00174 svn_error_quick_wrap(svn_error_t *child, 00175 const char *new_msg); 00176 00177 /** Like svn_error_quick_wrap(), but with format string support. 00178 * 00179 * @since New in 1.9. 00180 */ 00181 svn_error_t * 00182 svn_error_quick_wrapf(svn_error_t *child, 00183 const char *fmt, 00184 ...) 00185 __attribute__((format(printf, 2, 3))); 00186 00187 /** Compose two errors, returning the composition as a brand new error 00188 * and consuming the original errors. Either or both of @a err1 and 00189 * @a err2 may be @c SVN_NO_ERROR. If both are not @c SVN_NO_ERROR, 00190 * @a err2 will follow @a err1 in the chain of the returned error. 00191 * 00192 * Either @a err1 or @a err2 can be functions that return svn_error_t* 00193 * but if both are functions they can be evaluated in either order as 00194 * per the C language rules. 00195 * 00196 * @since New in 1.6. 00197 */ 00198 svn_error_t * 00199 svn_error_compose_create(svn_error_t *err1, 00200 svn_error_t *err2); 00201 00202 /** Add @a new_err to the end of @a chain's chain of errors. The @a new_err 00203 * chain will be copied into @a chain's pool and destroyed, so @a new_err 00204 * itself becomes invalid after this function. 00205 * 00206 * Either @a chain or @a new_err can be functions that return svn_error_t* 00207 * but if both are functions they can be evaluated in either order as 00208 * per the C language rules. 00209 */ 00210 void 00211 svn_error_compose(svn_error_t *chain, 00212 svn_error_t *new_err); 00213 00214 /** Return the root cause of @a err by finding the last error in its 00215 * chain (e.g. it or its children). @a err may be @c SVN_NO_ERROR, in 00216 * which case @c SVN_NO_ERROR is returned. The returned error should 00217 * @em not be cleared as it shares memory with @a err. 00218 * 00219 * @since New in 1.5. 00220 */ 00221 svn_error_t * 00222 svn_error_root_cause(svn_error_t *err); 00223 00224 /** Return the first error in @a err's chain that has an error code @a 00225 * apr_err or #SVN_NO_ERROR if there is no error with that code. The 00226 * returned error should @em not be cleared as it shares memory with @a err. 00227 * 00228 * If @a err is #SVN_NO_ERROR, return #SVN_NO_ERROR. 00229 * 00230 * @since New in 1.7. 00231 */ 00232 svn_error_t * 00233 svn_error_find_cause(svn_error_t *err, apr_status_t apr_err); 00234 00235 /** Create a new error that is a deep copy of @a err and return it. 00236 * 00237 * @since New in 1.2. 00238 */ 00239 svn_error_t * 00240 svn_error_dup(const svn_error_t *err); 00241 00242 /** Free the memory used by @a error, as well as all ancestors and 00243 * descendants of @a error. 00244 * 00245 * Unlike other Subversion objects, errors are managed explicitly; you 00246 * MUST clear an error if you are ignoring it, or you are leaking memory. 00247 * For convenience, @a error may be @c NULL, in which case this function does 00248 * nothing; thus, svn_error_clear(svn_foo(...)) works as an idiom to 00249 * ignore errors. 00250 */ 00251 void 00252 svn_error_clear(svn_error_t *error); 00253 00254 00255 #if defined(SVN_ERR__TRACING) 00256 /** Set the error location for debug mode. */ 00257 void 00258 svn_error__locate(const char *file, 00259 long line); 00260 00261 /* Wrapper macros to collect file and line information */ 00262 #define svn_error_create \ 00263 (svn_error__locate(__FILE__,__LINE__), (svn_error_create)) 00264 #define svn_error_createf \ 00265 (svn_error__locate(__FILE__,__LINE__), (svn_error_createf)) 00266 #define svn_error_wrap_apr \ 00267 (svn_error__locate(__FILE__,__LINE__), (svn_error_wrap_apr)) 00268 #define svn_error_quick_wrap \ 00269 (svn_error__locate(__FILE__,__LINE__), (svn_error_quick_wrap)) 00270 #define svn_error_quick_wrapf \ 00271 (svn_error__locate(__FILE__,__LINE__), (svn_error_quick_wrapf)) 00272 #endif 00273 00274 00275 /** 00276 * Very basic default error handler: print out error stack @a error to the 00277 * stdio stream @a stream, with each error prefixed by @a prefix; quit and 00278 * clear @a error iff the @a fatal flag is set. Allocations are performed 00279 * in the @a error's pool. 00280 * 00281 * If you're not sure what prefix to pass, just pass "svn: ". That's 00282 * what code that used to call svn_handle_error() and now calls 00283 * svn_handle_error2() does. 00284 * 00285 * Note that this should only be used from commandline specific code, or 00286 * code that knows that @a stream is really where the application wants 00287 * to receive its errors on. 00288 * 00289 * @since New in 1.2. 00290 */ 00291 void 00292 svn_handle_error2(svn_error_t *error, 00293 FILE *stream, 00294 svn_boolean_t fatal, 00295 const char *prefix); 00296 00297 /** Like svn_handle_error2() but with @c prefix set to "svn: " 00298 * 00299 * @deprecated Provided for backward compatibility with the 1.1 API. 00300 */ 00301 SVN_DEPRECATED 00302 void 00303 svn_handle_error(svn_error_t *error, 00304 FILE *stream, 00305 svn_boolean_t fatal); 00306 00307 /** 00308 * Very basic default warning handler: print out the error @a error to the 00309 * stdio stream @a stream, prefixed by @a prefix. Allocations are 00310 * performed in the error's pool. 00311 * 00312 * @a error may not be @c NULL. 00313 * 00314 * @note This does not clear @a error. 00315 * 00316 * @since New in 1.2. 00317 */ 00318 void 00319 svn_handle_warning2(FILE *stream, 00320 const svn_error_t *error, 00321 const char *prefix); 00322 00323 /** Like svn_handle_warning2() but with @c prefix set to "svn: " 00324 * 00325 * @deprecated Provided for backward compatibility with the 1.1 API. 00326 */ 00327 SVN_DEPRECATED 00328 void 00329 svn_handle_warning(FILE *stream, 00330 svn_error_t *error); 00331 00332 00333 /** A statement macro for checking error values. 00334 * 00335 * Evaluate @a expr. If it yields an error, return that error from the 00336 * current function. Otherwise, continue. 00337 * 00338 * The <tt>do { ... } while (0)</tt> wrapper has no semantic effect, 00339 * but it makes this macro syntactically equivalent to the expression 00340 * statement it resembles. Without it, statements like 00341 * 00342 * @code 00343 * if (a) 00344 * SVN_ERR(some operation); 00345 * else 00346 * foo; 00347 * @endcode 00348 * 00349 * would not mean what they appear to. 00350 */ 00351 #define SVN_ERR(expr) \ 00352 do { \ 00353 svn_error_t *svn_err__temp = (expr); \ 00354 if (svn_err__temp) \ 00355 return svn_error_trace(svn_err__temp); \ 00356 } while (0) 00357 00358 /** 00359 * A macro for wrapping an error in a source-location trace message. 00360 * 00361 * This macro can be used when directly returning an already created 00362 * error (when not using SVN_ERR, svn_error_create(), etc.) to ensure 00363 * that the call stack is recorded correctly. 00364 * 00365 * @since New in 1.7. 00366 */ 00367 #ifdef SVN_ERR__TRACING 00368 svn_error_t * 00369 svn_error__trace(const char *file, long line, svn_error_t *err); 00370 00371 #define svn_error_trace(expr) svn_error__trace(__FILE__, __LINE__, (expr)) 00372 #else 00373 #define svn_error_trace(expr) (expr) 00374 #endif 00375 00376 /** 00377 * Returns an error chain that is based on @a err's error chain but 00378 * does not include any error tracing placeholders. @a err is not 00379 * modified, except for any allocations using its pool. 00380 * 00381 * The returned error chain is allocated from @a err's pool and shares 00382 * its message and source filename character arrays. The returned 00383 * error chain should *not* be cleared because it is not a fully 00384 * fledged error chain, only clearing @a err should be done to clear 00385 * the returned error chain. If @a err is cleared, then the returned 00386 * error chain is unusable. 00387 * 00388 * @a err can be #SVN_NO_ERROR. If @a err is not #SVN_NO_ERROR, then 00389 * the last link in the error chain must be a non-tracing error, i.e, 00390 * a real error. 00391 * 00392 * @since New in 1.7. 00393 */ 00394 svn_error_t *svn_error_purge_tracing(svn_error_t *err); 00395 00396 00397 /** A statement macro, very similar to @c SVN_ERR. 00398 * 00399 * This macro will wrap the error with the specified text before 00400 * returning the error. 00401 */ 00402 #define SVN_ERR_W(expr, wrap_msg) \ 00403 do { \ 00404 svn_error_t *svn_err__temp = (expr); \ 00405 if (svn_err__temp) \ 00406 return svn_error_quick_wrap(svn_err__temp, wrap_msg); \ 00407 } while (0) 00408 00409 00410 /** A statement macro intended for the main() function of the 'svn' program. 00411 * 00412 * Evaluate @a expr. If it yields an error, display the error on stdout 00413 * and return @c EXIT_FAILURE. 00414 * 00415 * @note Not for use in the library, as it prints to stderr. This macro 00416 * no longer suits the needs of the 'svn' program, and is not generally 00417 * suitable for third-party use as it assumes the program name is 'svn'. 00418 * 00419 * @deprecated Provided for backward compatibility with the 1.8 API. Consider 00420 * using svn_handle_error2() or svn_cmdline_handle_exit_error() instead. 00421 */ 00422 #define SVN_INT_ERR(expr) \ 00423 do { \ 00424 svn_error_t *svn_err__temp = (expr); \ 00425 if (svn_err__temp) { \ 00426 svn_handle_error2(svn_err__temp, stderr, FALSE, "svn: "); \ 00427 svn_error_clear(svn_err__temp); \ 00428 return EXIT_FAILURE; } \ 00429 } while (0) 00430 00431 /** @} */ 00432 00433 00434 /** Error groups 00435 * 00436 * @defgroup svn_error_error_groups Error groups 00437 * @{ 00438 */ 00439 00440 /** 00441 * Return TRUE if @a err is an error specifically related to locking a 00442 * path in the repository, FALSE otherwise. 00443 * 00444 * SVN_ERR_FS_OUT_OF_DATE and SVN_ERR_FS_NOT_FOUND are in here because it's a 00445 * non-fatal error that can be thrown when attempting to lock an item. 00446 * 00447 * SVN_ERR_REPOS_HOOK_FAILURE refers to the pre-lock hook. 00448 * 00449 * @since New in 1.2. 00450 */ 00451 #define SVN_ERR_IS_LOCK_ERROR(err) \ 00452 (err->apr_err == SVN_ERR_FS_PATH_ALREADY_LOCKED || \ 00453 err->apr_err == SVN_ERR_FS_NOT_FOUND || \ 00454 err->apr_err == SVN_ERR_FS_OUT_OF_DATE || \ 00455 err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN || \ 00456 err->apr_err == SVN_ERR_REPOS_HOOK_FAILURE || \ 00457 err->apr_err == SVN_ERR_FS_NO_SUCH_REVISION || \ 00458 err->apr_err == SVN_ERR_FS_OUT_OF_DATE || \ 00459 err->apr_err == SVN_ERR_FS_NOT_FILE) 00460 00461 /** 00462 * Return TRUE if @a err is an error specifically related to unlocking 00463 * a path in the repository, FALSE otherwise. 00464 * 00465 * SVN_ERR_REPOS_HOOK_FAILURE refers to the pre-unlock hook. 00466 * 00467 * @since New in 1.2. 00468 */ 00469 #define SVN_ERR_IS_UNLOCK_ERROR(err) \ 00470 (err->apr_err == SVN_ERR_FS_PATH_NOT_LOCKED || \ 00471 err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN || \ 00472 err->apr_err == SVN_ERR_FS_LOCK_OWNER_MISMATCH || \ 00473 err->apr_err == SVN_ERR_FS_NO_SUCH_LOCK || \ 00474 err->apr_err == SVN_ERR_RA_NOT_LOCKED || \ 00475 err->apr_err == SVN_ERR_FS_LOCK_EXPIRED || \ 00476 err->apr_err == SVN_ERR_REPOS_HOOK_FAILURE) 00477 00478 /** Evaluates to @c TRUE iff @a apr_err (of type apr_status_t) is in the given 00479 * @a category, which should be one of the @c SVN_ERR_*_CATEGORY_START 00480 * constants. 00481 * 00482 * @since New in 1.7. 00483 */ 00484 #define SVN_ERROR_IN_CATEGORY(apr_err, category) \ 00485 ((category) == ((apr_err) / SVN_ERR_CATEGORY_SIZE) * SVN_ERR_CATEGORY_SIZE) 00486 00487 00488 /** @} */ 00489 00490 00491 /** Internal malfunctions and assertions 00492 * 00493 * @defgroup svn_error_malfunction_assertion Malfunctions and assertions 00494 * @{ 00495 */ 00496 00497 /** Report that an internal malfunction has occurred, and possibly terminate 00498 * the program. 00499 * 00500 * Act as determined by the current "malfunction handler" which may have 00501 * been specified by a call to svn_error_set_malfunction_handler() or else 00502 * is the default handler as specified in that function's documentation. If 00503 * the malfunction handler returns, then cause the function using this macro 00504 * to return the error object that it generated. 00505 * 00506 * @note The intended use of this macro is where execution reaches a point 00507 * that cannot possibly be reached unless there is a bug in the program. 00508 * 00509 * @since New in 1.6. 00510 */ 00511 #define SVN_ERR_MALFUNCTION() \ 00512 do { \ 00513 return svn_error_trace(svn_error__malfunction( \ 00514 TRUE, __FILE__, __LINE__, NULL)); \ 00515 } while (0) 00516 00517 /** Similar to SVN_ERR_MALFUNCTION(), but without the option of returning 00518 * an error to the calling function. 00519 * 00520 * If possible you should use SVN_ERR_MALFUNCTION() instead. 00521 * 00522 * @since New in 1.6. 00523 */ 00524 #define SVN_ERR_MALFUNCTION_NO_RETURN() \ 00525 do { \ 00526 svn_error__malfunction(FALSE, __FILE__, __LINE__, NULL); \ 00527 abort(); \ 00528 } while (1) 00529 00530 /** Like SVN_ERR_ASSERT(), but append ERR to the returned error chain. 00531 * 00532 * If EXPR is false, return a malfunction error whose chain includes ERR. 00533 * If EXPR is true, do nothing. (In particular, this does not clear ERR.) 00534 * 00535 * Types: (svn_boolean_t expr, svn_error_t *err) 00536 * 00537 * @since New in 1.8. 00538 */ 00539 #ifdef __clang_analyzer__ 00540 #include <assert.h> 00541 /* Just ignore ERR. If the assert triggers, it'll be our least concern. */ 00542 #define SVN_ERR_ASSERT_E(expr, err) assert((expr)) 00543 #else 00544 #define SVN_ERR_ASSERT_E(expr, err) \ 00545 do { \ 00546 if (!(expr)) { \ 00547 return svn_error_compose_create( \ 00548 svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr), \ 00549 (err)); \ 00550 } \ 00551 } while (0) 00552 #endif 00553 00554 00555 /** Check that a condition is true: if not, report an error and possibly 00556 * terminate the program. 00557 * 00558 * If the Boolean expression @a expr is true, do nothing. Otherwise, 00559 * act as determined by the current "malfunction handler" which may have 00560 * been specified by a call to svn_error_set_malfunction_handler() or else 00561 * is the default handler as specified in that function's documentation. If 00562 * the malfunction handler returns, then cause the function using this macro 00563 * to return the error object that it generated. 00564 * 00565 * @note The intended use of this macro is to check a condition that cannot 00566 * possibly be false unless there is a bug in the program. 00567 * 00568 * @note The condition to be checked should not be computationally expensive 00569 * if it is reached often, as, unlike traditional "assert" statements, the 00570 * evaluation of this expression is not compiled out in release-mode builds. 00571 * 00572 * @since New in 1.6. 00573 * 00574 * @see SVN_ERR_ASSERT_E() 00575 */ 00576 #ifdef __clang_analyzer__ 00577 #include <assert.h> 00578 #define SVN_ERR_ASSERT(expr) assert((expr)) 00579 #else 00580 #define SVN_ERR_ASSERT(expr) \ 00581 do { \ 00582 if (!(expr)) \ 00583 SVN_ERR(svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr)); \ 00584 } while (0) 00585 #endif 00586 00587 /** Similar to SVN_ERR_ASSERT(), but without the option of returning 00588 * an error to the calling function. 00589 * 00590 * If possible you should use SVN_ERR_ASSERT() instead. 00591 * 00592 * @since New in 1.6. 00593 */ 00594 #define SVN_ERR_ASSERT_NO_RETURN(expr) \ 00595 do { \ 00596 if (!(expr)) { \ 00597 svn_error__malfunction(FALSE, __FILE__, __LINE__, #expr); \ 00598 abort(); \ 00599 } \ 00600 } while (0) 00601 00602 /** Report a "Not implemented" malfunction. Internal use only. */ 00603 #define SVN__NOT_IMPLEMENTED() \ 00604 return svn_error__malfunction(TRUE, __FILE__, __LINE__, "Not implemented.") 00605 00606 /** A helper function for the macros that report malfunctions. Handle a 00607 * malfunction by calling the current "malfunction handler" which may have 00608 * been specified by a call to svn_error_set_malfunction_handler() or else 00609 * is the default handler as specified in that function's documentation. 00610 * 00611 * Pass all of the parameters to the handler. The error occurred in the 00612 * source file @a file at line @a line, and was an assertion failure of the 00613 * expression @a expr, or, if @a expr is null, an unconditional error. 00614 * 00615 * If @a can_return is true, the handler can return an error object 00616 * that is returned by the caller. If @a can_return is false the 00617 * method should never return. (The caller will call abort()) 00618 * 00619 * @since New in 1.6. 00620 */ 00621 svn_error_t * 00622 svn_error__malfunction(svn_boolean_t can_return, 00623 const char *file, 00624 int line, 00625 const char *expr); 00626 00627 /** A type of function that handles an assertion failure or other internal 00628 * malfunction detected within the Subversion libraries. 00629 * 00630 * The error occurred in the source file @a file at line @a line, and was an 00631 * assertion failure of the expression @a expr, or, if @a expr is null, an 00632 * unconditional error. 00633 * 00634 * If @a can_return is false a function of this type must never return. 00635 * 00636 * If @a can_return is true a function of this type must do one of: 00637 * - Return an error object describing the error, using an error code in 00638 * the category SVN_ERR_MALFUNC_CATEGORY_START. 00639 * - Never return. 00640 * 00641 * The function may alter its behaviour according to compile-time 00642 * and run-time and even interactive conditions. 00643 * 00644 * @see SVN_ERROR_IN_CATEGORY() 00645 * 00646 * @since New in 1.6. 00647 */ 00648 typedef svn_error_t *(*svn_error_malfunction_handler_t) 00649 (svn_boolean_t can_return, const char *file, int line, const char *expr); 00650 00651 /** Cause subsequent malfunctions to be handled by @a func. 00652 * Return the handler that was previously in effect. 00653 * 00654 * @a func may not be null. 00655 * 00656 * @note The default handler is svn_error_abort_on_malfunction(). 00657 * 00658 * @note This function must be called in a single-threaded context. 00659 * 00660 * @since New in 1.6. 00661 */ 00662 svn_error_malfunction_handler_t 00663 svn_error_set_malfunction_handler(svn_error_malfunction_handler_t func); 00664 00665 /** Return the malfunction handler that is currently in effect. 00666 * @since New in 1.9. */ 00667 svn_error_malfunction_handler_t 00668 svn_error_get_malfunction_handler(void); 00669 00670 /** Handle a malfunction by returning an error object that describes it. 00671 * 00672 * When @a can_return is false, abort() 00673 * 00674 * This function implements @c svn_error_malfunction_handler_t. 00675 * 00676 * @since New in 1.6. 00677 */ 00678 svn_error_t * 00679 svn_error_raise_on_malfunction(svn_boolean_t can_return, 00680 const char *file, 00681 int line, 00682 const char *expr); 00683 00684 /** Handle a malfunction by printing a message to stderr and aborting. 00685 * 00686 * This function implements @c svn_error_malfunction_handler_t. 00687 * 00688 * @since New in 1.6. 00689 */ 00690 svn_error_t * 00691 svn_error_abort_on_malfunction(svn_boolean_t can_return, 00692 const char *file, 00693 int line, 00694 const char *expr); 00695 00696 /** @} */ 00697 00698 00699 #ifdef __cplusplus 00700 } 00701 #endif /* __cplusplus */ 00702 00703 #endif /* SVN_ERROR_H */
1.6.1