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 /** A quick n' easy way to create a wrapped exception with your own 00169 * message, before throwing it up the stack. (It uses all of the 00170 * @a child's fields.) 00171 */ 00172 svn_error_t * 00173 svn_error_quick_wrap(svn_error_t *child, 00174 const char *new_msg); 00175 00176 /** A quick n' easy way to create a wrapped exception with your own 00177 * printf-style error message produced by passing @a fmt, using 00178 * apr_psprintf(), before throwing it up the stack. (It uses all of the 00179 * @a child's fields.) 00180 * 00181 * @since New in 1.9. 00182 */ 00183 svn_error_t * 00184 svn_error_quick_wrapf(svn_error_t *child, 00185 const char *fmt, 00186 ...) 00187 __attribute__((format(printf, 2, 3))); 00188 00189 /** Compose two errors, returning the composition as a brand new error 00190 * and consuming the original errors. Either or both of @a err1 and 00191 * @a err2 may be @c SVN_NO_ERROR. If both are not @c SVN_NO_ERROR, 00192 * @a err2 will follow @a err1 in the chain of the returned error. 00193 * 00194 * Either @a err1 or @a err2 can be functions that return svn_error_t* 00195 * but if both are functions they can be evaluated in either order as 00196 * per the C language rules. 00197 * 00198 * @since New in 1.6. 00199 */ 00200 svn_error_t * 00201 svn_error_compose_create(svn_error_t *err1, 00202 svn_error_t *err2); 00203 00204 /** Add @a new_err to the end of @a chain's chain of errors. The @a new_err 00205 * chain will be copied into @a chain's pool and destroyed, so @a new_err 00206 * itself becomes invalid after this function. 00207 * 00208 * Either @a chain or @a new_err can be functions that return svn_error_t* 00209 * but if both are functions they can be evaluated in either order as 00210 * per the C language rules. 00211 */ 00212 void 00213 svn_error_compose(svn_error_t *chain, 00214 svn_error_t *new_err); 00215 00216 /** Return the root cause of @a err by finding the last error in its 00217 * chain (e.g. it or its children). @a err may be @c SVN_NO_ERROR, in 00218 * which case @c SVN_NO_ERROR is returned. The returned error should 00219 * @em not be cleared as it shares memory with @a err. 00220 * 00221 * @since New in 1.5. 00222 */ 00223 svn_error_t * 00224 svn_error_root_cause(svn_error_t *err); 00225 00226 /** Return the first error in @a err's chain that has an error code @a 00227 * apr_err or #SVN_NO_ERROR if there is no error with that code. The 00228 * returned error should @em not be cleared as it shares memory with @a err. 00229 * 00230 * If @a err is #SVN_NO_ERROR, return #SVN_NO_ERROR. 00231 * 00232 * @since New in 1.7. 00233 */ 00234 svn_error_t * 00235 svn_error_find_cause(svn_error_t *err, apr_status_t apr_err); 00236 00237 /** Create a new error that is a deep copy of @a err and return it. 00238 * 00239 * @since New in 1.2. 00240 */ 00241 svn_error_t * 00242 svn_error_dup(const svn_error_t *err); 00243 00244 /** Free the memory used by @a error, as well as all ancestors and 00245 * descendants of @a error. 00246 * 00247 * Unlike other Subversion objects, errors are managed explicitly; you 00248 * MUST clear an error if you are ignoring it, or you are leaking memory. 00249 * For convenience, @a error may be @c NULL, in which case this function does 00250 * nothing; thus, svn_error_clear(svn_foo(...)) works as an idiom to 00251 * ignore errors. 00252 */ 00253 void 00254 svn_error_clear(svn_error_t *error); 00255 00256 00257 #if defined(SVN_ERR__TRACING) 00258 /** Set the error location for debug mode. */ 00259 void 00260 svn_error__locate(const char *file, 00261 long line); 00262 00263 /* Wrapper macros to collect file and line information */ 00264 #define svn_error_create \ 00265 (svn_error__locate(__FILE__,__LINE__), (svn_error_create)) 00266 #define svn_error_createf \ 00267 (svn_error__locate(__FILE__,__LINE__), (svn_error_createf)) 00268 #define svn_error_wrap_apr \ 00269 (svn_error__locate(__FILE__,__LINE__), (svn_error_wrap_apr)) 00270 #define svn_error_quick_wrap \ 00271 (svn_error__locate(__FILE__,__LINE__), (svn_error_quick_wrap)) 00272 #define svn_error_quick_wrapf \ 00273 (svn_error__locate(__FILE__,__LINE__), (svn_error_quick_wrapf)) 00274 #endif 00275 00276 00277 /** 00278 * Very basic default error handler: print out error stack @a error to the 00279 * stdio stream @a stream, with each error prefixed by @a prefix; quit and 00280 * clear @a error iff the @a fatal flag is set. Allocations are performed 00281 * in the @a error's pool. 00282 * 00283 * If you're not sure what prefix to pass, just pass "svn: ". That's 00284 * what code that used to call svn_handle_error() and now calls 00285 * svn_handle_error2() does. 00286 * 00287 * Note that this should only be used from commandline specific code, or 00288 * code that knows that @a stream is really where the application wants 00289 * to receive its errors on. 00290 * 00291 * @since New in 1.2. 00292 */ 00293 void 00294 svn_handle_error2(svn_error_t *error, 00295 FILE *stream, 00296 svn_boolean_t fatal, 00297 const char *prefix); 00298 00299 /** Like svn_handle_error2() but with @c prefix set to "svn: " 00300 * 00301 * @deprecated Provided for backward compatibility with the 1.1 API. 00302 */ 00303 SVN_DEPRECATED 00304 void 00305 svn_handle_error(svn_error_t *error, 00306 FILE *stream, 00307 svn_boolean_t fatal); 00308 00309 /** 00310 * Very basic default warning handler: print out the error @a error to the 00311 * stdio stream @a stream, prefixed by @a prefix. Allocations are 00312 * performed in the error's pool. 00313 * 00314 * @a error may not be @c NULL. 00315 * 00316 * @note This does not clear @a error. 00317 * 00318 * @since New in 1.2. 00319 */ 00320 void 00321 svn_handle_warning2(FILE *stream, 00322 const svn_error_t *error, 00323 const char *prefix); 00324 00325 /** Like svn_handle_warning2() but with @c prefix set to "svn: " 00326 * 00327 * @deprecated Provided for backward compatibility with the 1.1 API. 00328 */ 00329 SVN_DEPRECATED 00330 void 00331 svn_handle_warning(FILE *stream, 00332 svn_error_t *error); 00333 00334 00335 /** A statement macro for checking error values. 00336 * 00337 * Evaluate @a expr. If it yields an error, return that error from the 00338 * current function. Otherwise, continue. 00339 * 00340 * The <tt>do { ... } while (0)</tt> wrapper has no semantic effect, 00341 * but it makes this macro syntactically equivalent to the expression 00342 * statement it resembles. Without it, statements like 00343 * 00344 * @code 00345 * if (a) 00346 * SVN_ERR(some operation); 00347 * else 00348 * foo; 00349 * @endcode 00350 * 00351 * would not mean what they appear to. 00352 */ 00353 #define SVN_ERR(expr) \ 00354 do { \ 00355 svn_error_t *svn_err__temp = (expr); \ 00356 if (svn_err__temp) \ 00357 return svn_error_trace(svn_err__temp); \ 00358 } while (0) 00359 00360 /** 00361 * A macro for wrapping an error in a source-location trace message. 00362 * 00363 * This macro can be used when directly returning an already created 00364 * error (when not using SVN_ERR, svn_error_create(), etc.) to ensure 00365 * that the call stack is recorded correctly. 00366 * 00367 * @since New in 1.7. 00368 */ 00369 #ifdef SVN_ERR__TRACING 00370 svn_error_t * 00371 svn_error__trace(const char *file, long line, svn_error_t *err); 00372 00373 #define svn_error_trace(expr) svn_error__trace(__FILE__, __LINE__, (expr)) 00374 #else 00375 #define svn_error_trace(expr) (expr) 00376 #endif 00377 00378 /** 00379 * Returns an error chain that is based on @a err's error chain but 00380 * does not include any error tracing placeholders. @a err is not 00381 * modified, except for any allocations using its pool. 00382 * 00383 * The returned error chain is allocated from @a err's pool and shares 00384 * its message and source filename character arrays. The returned 00385 * error chain should *not* be cleared because it is not a fully 00386 * fledged error chain, only clearing @a err should be done to clear 00387 * the returned error chain. If @a err is cleared, then the returned 00388 * error chain is unusable. 00389 * 00390 * @a err can be #SVN_NO_ERROR. If @a err is not #SVN_NO_ERROR, then 00391 * the last link in the error chain must be a non-tracing error, i.e, 00392 * a real error. 00393 * 00394 * @since New in 1.7. 00395 */ 00396 svn_error_t *svn_error_purge_tracing(svn_error_t *err); 00397 00398 00399 /** A statement macro, very similar to @c SVN_ERR. 00400 * 00401 * This macro will wrap the error with the specified text before 00402 * returning the error. 00403 */ 00404 #define SVN_ERR_W(expr, wrap_msg) \ 00405 do { \ 00406 svn_error_t *svn_err__temp = (expr); \ 00407 if (svn_err__temp) \ 00408 return svn_error_quick_wrap(svn_err__temp, wrap_msg); \ 00409 } while (0) 00410 00411 00412 /** A statement macro intended for the main() function of the 'svn' program. 00413 * 00414 * Evaluate @a expr. If it yields an error, display the error on stdout 00415 * and return @c EXIT_FAILURE. 00416 * 00417 * @note Not for use in the library, as it prints to stderr. This macro 00418 * no longer suits the needs of the 'svn' program, and is not generally 00419 * suitable for third-party use as it assumes the program name is 'svn'. 00420 * 00421 * @deprecated Provided for backward compatibility with the 1.8 API. Consider 00422 * using svn_handle_error2() or svn_cmdline_handle_exit_error() instead. 00423 */ 00424 #define SVN_INT_ERR(expr) \ 00425 do { \ 00426 svn_error_t *svn_err__temp = (expr); \ 00427 if (svn_err__temp) { \ 00428 svn_handle_error2(svn_err__temp, stderr, FALSE, "svn: "); \ 00429 svn_error_clear(svn_err__temp); \ 00430 return EXIT_FAILURE; } \ 00431 } while (0) 00432 00433 /** @} */ 00434 00435 00436 /** Error groups 00437 * 00438 * @defgroup svn_error_error_groups Error groups 00439 * @{ 00440 */ 00441 00442 /** 00443 * Return TRUE if @a err is an error specifically related to locking a 00444 * path in the repository, FALSE otherwise. 00445 * 00446 * SVN_ERR_FS_OUT_OF_DATE and SVN_ERR_FS_NOT_FOUND are in here because it's a 00447 * non-fatal error that can be thrown when attempting to lock an item. 00448 * 00449 * SVN_ERR_REPOS_HOOK_FAILURE refers to the pre-lock hook. 00450 * 00451 * @since New in 1.2. 00452 */ 00453 #define SVN_ERR_IS_LOCK_ERROR(err) \ 00454 (err->apr_err == SVN_ERR_FS_PATH_ALREADY_LOCKED || \ 00455 err->apr_err == SVN_ERR_FS_NOT_FOUND || \ 00456 err->apr_err == SVN_ERR_FS_OUT_OF_DATE || \ 00457 err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN || \ 00458 err->apr_err == SVN_ERR_REPOS_HOOK_FAILURE || \ 00459 err->apr_err == SVN_ERR_FS_NO_SUCH_REVISION || \ 00460 err->apr_err == SVN_ERR_FS_OUT_OF_DATE || \ 00461 err->apr_err == SVN_ERR_FS_NOT_FILE) 00462 00463 /** 00464 * Return TRUE if @a err is an error specifically related to unlocking 00465 * a path in the repository, FALSE otherwise. 00466 * 00467 * SVN_ERR_REPOS_HOOK_FAILURE refers to the pre-unlock hook. 00468 * 00469 * @since New in 1.2. 00470 */ 00471 #define SVN_ERR_IS_UNLOCK_ERROR(err) \ 00472 (err->apr_err == SVN_ERR_FS_PATH_NOT_LOCKED || \ 00473 err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN || \ 00474 err->apr_err == SVN_ERR_FS_LOCK_OWNER_MISMATCH || \ 00475 err->apr_err == SVN_ERR_FS_NO_SUCH_LOCK || \ 00476 err->apr_err == SVN_ERR_RA_NOT_LOCKED || \ 00477 err->apr_err == SVN_ERR_FS_LOCK_EXPIRED || \ 00478 err->apr_err == SVN_ERR_REPOS_HOOK_FAILURE) 00479 00480 /** Evaluates to @c TRUE iff @a apr_err (of type apr_status_t) is in the given 00481 * @a category, which should be one of the @c SVN_ERR_*_CATEGORY_START 00482 * constants. 00483 * 00484 * @since New in 1.7. 00485 */ 00486 #define SVN_ERROR_IN_CATEGORY(apr_err, category) \ 00487 ((category) == ((apr_err) / SVN_ERR_CATEGORY_SIZE) * SVN_ERR_CATEGORY_SIZE) 00488 00489 00490 /** @} */ 00491 00492 00493 /** Internal malfunctions and assertions 00494 * 00495 * @defgroup svn_error_malfunction_assertion Malfunctions and assertions 00496 * @{ 00497 */ 00498 00499 /** Report that an internal malfunction has occurred, and possibly terminate 00500 * the program. 00501 * 00502 * Act as determined by the current "malfunction handler" which may have 00503 * been specified by a call to svn_error_set_malfunction_handler() or else 00504 * is the default handler as specified in that function's documentation. If 00505 * the malfunction handler returns, then cause the function using this macro 00506 * to return the error object that it generated. 00507 * 00508 * @note The intended use of this macro is where execution reaches a point 00509 * that cannot possibly be reached unless there is a bug in the program. 00510 * 00511 * @since New in 1.6. 00512 */ 00513 #define SVN_ERR_MALFUNCTION() \ 00514 do { \ 00515 return svn_error_trace(svn_error__malfunction( \ 00516 TRUE, __FILE__, __LINE__, NULL)); \ 00517 } while (0) 00518 00519 /** Similar to SVN_ERR_MALFUNCTION(), but without the option of returning 00520 * an error to the calling function. 00521 * 00522 * If possible you should use SVN_ERR_MALFUNCTION() instead. 00523 * 00524 * @since New in 1.6. 00525 */ 00526 #define SVN_ERR_MALFUNCTION_NO_RETURN() \ 00527 do { \ 00528 svn_error__malfunction(FALSE, __FILE__, __LINE__, NULL); \ 00529 abort(); \ 00530 } while (1) 00531 00532 /** Like SVN_ERR_ASSERT(), but append ERR to the returned error chain. 00533 * 00534 * If EXPR is false, return a malfunction error whose chain includes ERR. 00535 * If EXPR is true, do nothing. (In particular, this does not clear ERR.) 00536 * 00537 * Types: (svn_boolean_t expr, svn_error_t *err) 00538 * 00539 * @since New in 1.8. 00540 */ 00541 #ifdef __clang_analyzer__ 00542 #include <assert.h> 00543 /* Just ignore ERR. If the assert triggers, it'll be our least concern. */ 00544 #define SVN_ERR_ASSERT_E(expr, err) assert((expr)) 00545 #else 00546 #define SVN_ERR_ASSERT_E(expr, err) \ 00547 do { \ 00548 if (!(expr)) { \ 00549 return svn_error_compose_create( \ 00550 svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr), \ 00551 (err)); \ 00552 } \ 00553 } while (0) 00554 #endif 00555 00556 00557 /** Check that a condition is true: if not, report an error and possibly 00558 * terminate the program. 00559 * 00560 * If the Boolean expression @a expr is true, do nothing. Otherwise, 00561 * act as determined by the current "malfunction handler" which may have 00562 * been specified by a call to svn_error_set_malfunction_handler() or else 00563 * is the default handler as specified in that function's documentation. If 00564 * the malfunction handler returns, then cause the function using this macro 00565 * to return the error object that it generated. 00566 * 00567 * @note The intended use of this macro is to check a condition that cannot 00568 * possibly be false unless there is a bug in the program. 00569 * 00570 * @note The condition to be checked should not be computationally expensive 00571 * if it is reached often, as, unlike traditional "assert" statements, the 00572 * evaluation of this expression is not compiled out in release-mode builds. 00573 * 00574 * @since New in 1.6. 00575 * 00576 * @see SVN_ERR_ASSERT_E() 00577 */ 00578 #ifdef __clang_analyzer__ 00579 #include <assert.h> 00580 #define SVN_ERR_ASSERT(expr) assert((expr)) 00581 #else 00582 #define SVN_ERR_ASSERT(expr) \ 00583 do { \ 00584 if (!(expr)) \ 00585 SVN_ERR(svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr)); \ 00586 } while (0) 00587 #endif 00588 00589 /** Similar to SVN_ERR_ASSERT(), but without the option of returning 00590 * an error to the calling function. 00591 * 00592 * If possible you should use SVN_ERR_ASSERT() instead. 00593 * 00594 * @since New in 1.6. 00595 */ 00596 #define SVN_ERR_ASSERT_NO_RETURN(expr) \ 00597 do { \ 00598 if (!(expr)) { \ 00599 svn_error__malfunction(FALSE, __FILE__, __LINE__, #expr); \ 00600 abort(); \ 00601 } \ 00602 } while (0) 00603 00604 /** Report a "Not implemented" malfunction. Internal use only. */ 00605 #define SVN__NOT_IMPLEMENTED() \ 00606 return svn_error__malfunction(TRUE, __FILE__, __LINE__, "Not implemented.") 00607 00608 /** A helper function for the macros that report malfunctions. Handle a 00609 * malfunction by calling the current "malfunction handler" which may have 00610 * been specified by a call to svn_error_set_malfunction_handler() or else 00611 * is the default handler as specified in that function's documentation. 00612 * 00613 * Pass all of the parameters to the handler. The error occurred in the 00614 * source file @a file at line @a line, and was an assertion failure of the 00615 * expression @a expr, or, if @a expr is null, an unconditional error. 00616 * 00617 * If @a can_return is true, the handler can return an error object 00618 * that is returned by the caller. If @a can_return is false the 00619 * method should never return. (The caller will call abort()) 00620 * 00621 * @since New in 1.6. 00622 */ 00623 svn_error_t * 00624 svn_error__malfunction(svn_boolean_t can_return, 00625 const char *file, 00626 int line, 00627 const char *expr); 00628 00629 /** A type of function that handles an assertion failure or other internal 00630 * malfunction detected within the Subversion libraries. 00631 * 00632 * The error occurred in the source file @a file at line @a line, and was an 00633 * assertion failure of the expression @a expr, or, if @a expr is null, an 00634 * unconditional error. 00635 * 00636 * If @a can_return is false a function of this type must never return. 00637 * 00638 * If @a can_return is true a function of this type must do one of: 00639 * - Return an error object describing the error, using an error code in 00640 * the category SVN_ERR_MALFUNC_CATEGORY_START. 00641 * - Never return. 00642 * 00643 * The function may alter its behaviour according to compile-time 00644 * and run-time and even interactive conditions. 00645 * 00646 * @see SVN_ERROR_IN_CATEGORY() 00647 * 00648 * @since New in 1.6. 00649 */ 00650 typedef svn_error_t *(*svn_error_malfunction_handler_t) 00651 (svn_boolean_t can_return, const char *file, int line, const char *expr); 00652 00653 /** Cause subsequent malfunctions to be handled by @a func. 00654 * Return the handler that was previously in effect. 00655 * 00656 * @a func may not be null. 00657 * 00658 * @note The default handler is svn_error_abort_on_malfunction(). 00659 * 00660 * @note This function must be called in a single-threaded context. 00661 * 00662 * @since New in 1.6. 00663 */ 00664 svn_error_malfunction_handler_t 00665 svn_error_set_malfunction_handler(svn_error_malfunction_handler_t func); 00666 00667 /** Return the malfunction handler that is currently in effect. 00668 * @since New in 1.9. */ 00669 svn_error_malfunction_handler_t 00670 svn_error_get_malfunction_handler(void); 00671 00672 /** Handle a malfunction by returning an error object that describes it. 00673 * 00674 * When @a can_return is false, abort() 00675 * 00676 * This function implements @c svn_error_malfunction_handler_t. 00677 * 00678 * @since New in 1.6. 00679 */ 00680 svn_error_t * 00681 svn_error_raise_on_malfunction(svn_boolean_t can_return, 00682 const char *file, 00683 int line, 00684 const char *expr); 00685 00686 /** Handle a malfunction by printing a message to stderr and aborting. 00687 * 00688 * This function implements @c svn_error_malfunction_handler_t. 00689 * 00690 * @since New in 1.6. 00691 */ 00692 svn_error_t * 00693 svn_error_abort_on_malfunction(svn_boolean_t can_return, 00694 const char *file, 00695 int line, 00696 const char *expr); 00697 00698 /** @} */ 00699 00700 00701 #ifdef __cplusplus 00702 } 00703 #endif /* __cplusplus */ 00704 00705 #endif /* SVN_ERROR_H */
1.6.1