]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/subversion/subversion/include/svn_error.h
MFC r275385 (by bapt):
[FreeBSD/stable/10.git] / contrib / subversion / subversion / include / svn_error.h
1 /**
2  * @copyright
3  * ====================================================================
4  *    Licensed to the Apache Software Foundation (ASF) under one
5  *    or more contributor license agreements.  See the NOTICE file
6  *    distributed with this work for additional information
7  *    regarding copyright ownership.  The ASF licenses this file
8  *    to you under the Apache License, Version 2.0 (the
9  *    "License"); you may not use this file except in compliance
10  *    with the License.  You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  *    Unless required by applicable law or agreed to in writing,
15  *    software distributed under the License is distributed on an
16  *    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  *    KIND, either express or implied.  See the License for the
18  *    specific language governing permissions and limitations
19  *    under the License.
20  * ====================================================================
21  * @endcopyright
22  *
23  * @file svn_error.h
24  * @brief Common exception handling for Subversion.
25  */
26
27 #ifndef SVN_ERROR_H
28 #define SVN_ERROR_H
29
30 #include <apr.h>        /* for apr_size_t */
31 #include <apr_errno.h>  /* APR's error system */
32 #include <apr_pools.h>  /* for apr_pool_t */
33
34 #ifndef DOXYGEN_SHOULD_SKIP_THIS
35 #define APR_WANT_STDIO
36 #endif
37 #include <apr_want.h>   /* for FILE* */
38
39 #include "svn_types.h"
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif /* __cplusplus */
44
45
46 /* For the Subversion developers, this #define turns on extended "stack
47    traces" of any errors that get thrown. See the SVN_ERR() macro.  */
48 #ifdef SVN_DEBUG
49 #define SVN_ERR__TRACING
50 #endif
51
52
53 /** the best kind of (@c svn_error_t *) ! */
54 #define SVN_NO_ERROR   0
55
56 /* The actual error codes are kept in a separate file; see comments
57    there for the reasons why. */
58 #include "svn_error_codes.h"
59
60 /** Put an English description of @a statcode into @a buf and return @a buf,
61  * NULL-terminated. @a statcode is either an svn error or apr error.
62  */
63 char *
64 svn_strerror(apr_status_t statcode,
65              char *buf,
66              apr_size_t bufsize);
67
68
69 /**
70  * Return the symbolic name of an error code.  If the error code
71  * is in svn_error_codes.h, return the name of the macro as a string.
72  * If the error number is not recognised, return @c NULL.
73  *
74  * An error number may not be recognised because it was defined in a future
75  * version of Subversion (e.g., a 1.9.x server may transmit a defined-in-1.9.0
76  * error number to a 1.8.x client).
77  *
78  * An error number may be recognised @em incorrectly if the @c apr_status_t
79  * value originates in another library (such as libserf) which also uses APR.
80  * (This is a theoretical concern only: the @c apr_err member of #svn_error_t
81  * should never contain a "foreign" @c apr_status_t value, and
82  * in any case Subversion and Serf use non-overlapping subsets of the
83  * @c APR_OS_START_USERERR range.)
84  *
85  * Support for error codes returned by APR itself (i.e., not in the
86  * @c APR_OS_START_USERERR range, as defined in apr_errno.h) may be implemented
87  * in the future.
88  *
89  * @note In rare cases, a single numeric code has more than one symbolic name.
90  * (For example, #SVN_ERR_WC_NOT_DIRECTORY and #SVN_ERR_WC_NOT_WORKING_COPY).
91  * In those cases, it is not guaranteed which symbolic name is returned.
92  *
93  * @since New in 1.8.
94  */
95 const char *
96 svn_error_symbolic_name(apr_status_t statcode);
97
98
99 /** If @a err has a custom error message, return that, otherwise
100  * store the generic error string associated with @a err->apr_err into
101  * @a buf (terminating with NULL) and return @a buf.
102  *
103  * @since New in 1.4.
104  *
105  * @note @a buf and @a bufsize are provided in the interface so that
106  * this function is thread-safe and yet does no allocation.
107  */
108 const char *svn_err_best_message(const svn_error_t *err,
109                                  char *buf,
110                                  apr_size_t bufsize);
111
112
113 \f
114 /** SVN error creation and destruction.
115  *
116  * @defgroup svn_error_error_creation_destroy Error creation and destruction
117  * @{
118  */
119
120 /** Create a nested exception structure.
121  *
122  * Input:  an APR or SVN custom error code,
123  *         a "child" error to wrap,
124  *         a specific message
125  *
126  * Returns:  a new error structure (containing the old one).
127  *
128  * @note Errors are always allocated in a subpool of the global pool,
129  *        since an error's lifetime is generally not related to the
130  *        lifetime of any convenient pool.  Errors must be freed
131  *        with svn_error_clear().  The specific message should be @c NULL
132  *        if there is nothing to add to the general message associated
133  *        with the error code.
134  *
135  *        If creating the "bottommost" error in a chain, pass @c NULL for
136  *        the child argument.
137  */
138 svn_error_t *
139 svn_error_create(apr_status_t apr_err,
140                  svn_error_t *child,
141                  const char *message);
142
143 /** Create an error structure with the given @a apr_err and @a child,
144  * with a printf-style error message produced by passing @a fmt, using
145  * apr_psprintf().
146  */
147 svn_error_t *
148 svn_error_createf(apr_status_t apr_err,
149                   svn_error_t *child,
150                   const char *fmt,
151                   ...)
152   __attribute__ ((format(printf, 3, 4)));
153
154 /** Wrap a @a status from an APR function.  If @a fmt is NULL, this is
155  * equivalent to svn_error_create(status,NULL,NULL).  Otherwise,
156  * the error message is constructed by formatting @a fmt and the
157  * following arguments according to apr_psprintf(), and then
158  * appending ": " and the error message corresponding to @a status.
159  * (If UTF-8 translation of the APR error message fails, the ": " and
160  * APR error are not appended to the error message.)
161  */
162 svn_error_t *
163 svn_error_wrap_apr(apr_status_t status,
164                    const char *fmt,
165                    ...)
166        __attribute__((format(printf, 2, 3)));
167
168 /** A quick n' easy way to create a wrapped exception with your own
169  * message, before throwing it up the stack.  (It uses all of the
170  * @a child's fields.)
171  */
172 svn_error_t *
173 svn_error_quick_wrap(svn_error_t *child,
174                      const char *new_msg);
175
176 /** A quick n' easy way to create a wrapped exception with your own
177  * printf-style error message produced by passing @a fmt, using
178  * apr_psprintf(), before throwing it up the stack.  (It uses all of the
179  * @a child's fields.)
180  *
181  * @since New in 1.9.
182  */
183 svn_error_t *
184 svn_error_quick_wrapf(svn_error_t *child,
185                       const char *fmt,
186                       ...)
187        __attribute__((format(printf, 2, 3)));
188
189 /** Compose two errors, returning the composition as a brand new error
190  * and consuming the original errors.  Either or both of @a err1 and
191  * @a err2 may be @c SVN_NO_ERROR.  If both are not @c SVN_NO_ERROR,
192  * @a err2 will follow @a err1 in the chain of the returned error.
193  *
194  * Either @a err1 or @a err2 can be functions that return svn_error_t*
195  * but if both are functions they can be evaluated in either order as
196  * per the C language rules.
197  *
198  * @since New in 1.6.
199  */
200 svn_error_t *
201 svn_error_compose_create(svn_error_t *err1,
202                          svn_error_t *err2);
203
204 /** Add @a new_err to the end of @a chain's chain of errors.  The @a new_err
205  * chain will be copied into @a chain's pool and destroyed, so @a new_err
206  * itself becomes invalid after this function.
207  *
208  * Either @a chain or @a new_err can be functions that return svn_error_t*
209  * but if both are functions they can be evaluated in either order as
210  * per the C language rules.
211  */
212 void
213 svn_error_compose(svn_error_t *chain,
214                   svn_error_t *new_err);
215
216 /** Return the root cause of @a err by finding the last error in its
217  * chain (e.g. it or its children).  @a err may be @c SVN_NO_ERROR, in
218  * which case @c SVN_NO_ERROR is returned.  The returned error should
219  * @em not be cleared as it shares memory with @a err.
220  *
221  * @since New in 1.5.
222  */
223 svn_error_t *
224 svn_error_root_cause(svn_error_t *err);
225
226 /** Return the first error in @a err's chain that has an error code @a
227  * apr_err or #SVN_NO_ERROR if there is no error with that code.  The
228  * returned error should @em not be cleared as it shares memory with @a err.
229  *
230  * If @a err is #SVN_NO_ERROR, return #SVN_NO_ERROR.
231  *
232  * @since New in 1.7.
233  */
234 svn_error_t *
235 svn_error_find_cause(svn_error_t *err, apr_status_t apr_err);
236
237 /** Create a new error that is a deep copy of @a err and return it.
238  *
239  * @since New in 1.2.
240  */
241 svn_error_t *
242 svn_error_dup(const svn_error_t *err);
243
244 /** Free the memory used by @a error, as well as all ancestors and
245  * descendants of @a error.
246  *
247  * Unlike other Subversion objects, errors are managed explicitly; you
248  * MUST clear an error if you are ignoring it, or you are leaking memory.
249  * For convenience, @a error may be @c NULL, in which case this function does
250  * nothing; thus, svn_error_clear(svn_foo(...)) works as an idiom to
251  * ignore errors.
252  */
253 void
254 svn_error_clear(svn_error_t *error);
255
256
257 #if defined(SVN_ERR__TRACING)
258 /** Set the error location for debug mode. */
259 void
260 svn_error__locate(const char *file,
261                   long line);
262
263 /* Wrapper macros to collect file and line information */
264 #define svn_error_create \
265   (svn_error__locate(__FILE__,__LINE__), (svn_error_create))
266 #define svn_error_createf \
267   (svn_error__locate(__FILE__,__LINE__), (svn_error_createf))
268 #define svn_error_wrap_apr \
269   (svn_error__locate(__FILE__,__LINE__), (svn_error_wrap_apr))
270 #define svn_error_quick_wrap \
271   (svn_error__locate(__FILE__,__LINE__), (svn_error_quick_wrap))
272 #define svn_error_quick_wrapf \
273   (svn_error__locate(__FILE__,__LINE__), (svn_error_quick_wrapf))
274 #endif
275
276
277 /**
278  * Very basic default error handler: print out error stack @a error to the
279  * stdio stream @a stream, with each error prefixed by @a prefix; quit and
280  * clear @a error iff the @a fatal flag is set.  Allocations are performed
281  * in the @a error's pool.
282  *
283  * If you're not sure what prefix to pass, just pass "svn: ".  That's
284  * what code that used to call svn_handle_error() and now calls
285  * svn_handle_error2() does.
286  *
287  * Note that this should only be used from commandline specific code, or
288  * code that knows that @a stream is really where the application wants
289  * to receive its errors on.
290  *
291  * @since New in 1.2.
292  */
293 void
294 svn_handle_error2(svn_error_t *error,
295                   FILE *stream,
296                   svn_boolean_t fatal,
297                   const char *prefix);
298
299 /** Like svn_handle_error2() but with @c prefix set to "svn: "
300  *
301  * @deprecated Provided for backward compatibility with the 1.1 API.
302  */
303 SVN_DEPRECATED
304 void
305 svn_handle_error(svn_error_t *error,
306                  FILE *stream,
307                  svn_boolean_t fatal);
308
309 /**
310  * Very basic default warning handler: print out the error @a error to the
311  * stdio stream @a stream, prefixed by @a prefix.  Allocations are
312  * performed in the error's pool.
313  *
314  * @a error may not be @c NULL.
315  *
316  * @note This does not clear @a error.
317  *
318  * @since New in 1.2.
319  */
320 void
321 svn_handle_warning2(FILE *stream,
322                     const svn_error_t *error,
323                     const char *prefix);
324
325 /** Like svn_handle_warning2() but with @c prefix set to "svn: "
326  *
327  * @deprecated Provided for backward compatibility with the 1.1 API.
328  */
329 SVN_DEPRECATED
330 void
331 svn_handle_warning(FILE *stream,
332                    svn_error_t *error);
333
334
335 /** A statement macro for checking error values.
336  *
337  * Evaluate @a expr.  If it yields an error, return that error from the
338  * current function.  Otherwise, continue.
339  *
340  * The <tt>do { ... } while (0)</tt> wrapper has no semantic effect,
341  * but it makes this macro syntactically equivalent to the expression
342  * statement it resembles.  Without it, statements like
343  *
344  * @code
345  *   if (a)
346  *     SVN_ERR(some operation);
347  *   else
348  *     foo;
349  * @endcode
350  *
351  * would not mean what they appear to.
352  */
353 #define SVN_ERR(expr)                           \
354   do {                                          \
355     svn_error_t *svn_err__temp = (expr);        \
356     if (svn_err__temp)                          \
357       return svn_error_trace(svn_err__temp);    \
358   } while (0)
359
360 /**
361  * A macro for wrapping an error in a source-location trace message.
362  *
363  * This macro can be used when directly returning an already created
364  * error (when not using SVN_ERR, svn_error_create(), etc.) to ensure
365  * that the call stack is recorded correctly.
366  *
367  * @since New in 1.7.
368  */
369 #ifdef SVN_ERR__TRACING
370 svn_error_t *
371 svn_error__trace(const char *file, long line, svn_error_t *err);
372
373 #define svn_error_trace(expr)  svn_error__trace(__FILE__, __LINE__, (expr))
374 #else
375 #define svn_error_trace(expr)  (expr)
376 #endif
377
378 /**
379  * Returns an error chain that is based on @a err's error chain but
380  * does not include any error tracing placeholders.  @a err is not
381  * modified, except for any allocations using its pool.
382  *
383  * The returned error chain is allocated from @a err's pool and shares
384  * its message and source filename character arrays.  The returned
385  * error chain should *not* be cleared because it is not a fully
386  * fledged error chain, only clearing @a err should be done to clear
387  * the returned error chain.  If @a err is cleared, then the returned
388  * error chain is unusable.
389  *
390  * @a err can be #SVN_NO_ERROR.  If @a err is not #SVN_NO_ERROR, then
391  * the last link in the error chain must be a non-tracing error, i.e,
392  * a real error.
393  *
394  * @since New in 1.7.
395  */
396 svn_error_t *svn_error_purge_tracing(svn_error_t *err);
397
398
399 /** A statement macro, very similar to @c SVN_ERR.
400  *
401  * This macro will wrap the error with the specified text before
402  * returning the error.
403  */
404 #define SVN_ERR_W(expr, wrap_msg)                           \
405   do {                                                      \
406     svn_error_t *svn_err__temp = (expr);                    \
407     if (svn_err__temp)                                      \
408       return svn_error_quick_wrap(svn_err__temp, wrap_msg); \
409   } while (0)
410
411
412 /** A statement macro intended for the main() function of the 'svn' program.
413  *
414  * Evaluate @a expr. If it yields an error, display the error on stdout
415  * and return @c EXIT_FAILURE.
416  *
417  * @note Not for use in the library, as it prints to stderr. This macro
418  * no longer suits the needs of the 'svn' program, and is not generally
419  * suitable for third-party use as it assumes the program name is 'svn'.
420  *
421  * @deprecated Provided for backward compatibility with the 1.8 API. Consider
422  * using svn_handle_error2() or svn_cmdline_handle_exit_error() instead.
423  */
424 #define SVN_INT_ERR(expr)                                        \
425   do {                                                           \
426     svn_error_t *svn_err__temp = (expr);                         \
427     if (svn_err__temp) {                                         \
428       svn_handle_error2(svn_err__temp, stderr, FALSE, "svn: ");  \
429       svn_error_clear(svn_err__temp);                            \
430       return EXIT_FAILURE; }                                     \
431   } while (0)
432
433 /** @} */
434
435 \f
436 /** Error groups
437  *
438  * @defgroup svn_error_error_groups Error groups
439  * @{
440  */
441
442 /**
443  * Return TRUE if @a err is an error specifically related to locking a
444  * path in the repository, FALSE otherwise.
445  *
446  * SVN_ERR_FS_OUT_OF_DATE and SVN_ERR_FS_NOT_FOUND are in here because it's a
447  * non-fatal error that can be thrown when attempting to lock an item.
448  *
449  * SVN_ERR_REPOS_HOOK_FAILURE refers to the pre-lock hook.
450  *
451  * @since New in 1.2.
452  */
453 #define SVN_ERR_IS_LOCK_ERROR(err)                          \
454   (err->apr_err == SVN_ERR_FS_PATH_ALREADY_LOCKED ||        \
455    err->apr_err == SVN_ERR_FS_NOT_FOUND           ||        \
456    err->apr_err == SVN_ERR_FS_OUT_OF_DATE         ||        \
457    err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN      ||        \
458    err->apr_err == SVN_ERR_REPOS_HOOK_FAILURE     ||        \
459    err->apr_err == SVN_ERR_FS_NO_SUCH_REVISION    ||        \
460    err->apr_err == SVN_ERR_FS_OUT_OF_DATE         ||        \
461    err->apr_err == SVN_ERR_FS_NOT_FILE)
462
463 /**
464  * Return TRUE if @a err is an error specifically related to unlocking
465  * a path in the repository, FALSE otherwise.
466  *
467  * SVN_ERR_REPOS_HOOK_FAILURE refers to the pre-unlock hook.
468  *
469  * @since New in 1.2.
470  */
471 #define SVN_ERR_IS_UNLOCK_ERROR(err)                        \
472   (err->apr_err == SVN_ERR_FS_PATH_NOT_LOCKED ||            \
473    err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN ||             \
474    err->apr_err == SVN_ERR_FS_LOCK_OWNER_MISMATCH ||        \
475    err->apr_err == SVN_ERR_FS_NO_SUCH_LOCK ||               \
476    err->apr_err == SVN_ERR_RA_NOT_LOCKED ||                 \
477    err->apr_err == SVN_ERR_FS_LOCK_EXPIRED ||               \
478    err->apr_err == SVN_ERR_REPOS_HOOK_FAILURE)
479
480 /** Evaluates to @c TRUE iff @a apr_err (of type apr_status_t) is in the given
481  * @a category, which should be one of the @c SVN_ERR_*_CATEGORY_START
482  * constants.
483  *
484  * @since New in 1.7.
485  */
486 #define SVN_ERROR_IN_CATEGORY(apr_err, category)            \
487     ((category) == ((apr_err) / SVN_ERR_CATEGORY_SIZE) * SVN_ERR_CATEGORY_SIZE)
488
489
490 /** @} */
491
492 \f
493 /** Internal malfunctions and assertions
494  *
495  * @defgroup svn_error_malfunction_assertion Malfunctions and assertions
496  * @{
497  */
498
499 /** Report that an internal malfunction has occurred, and possibly terminate
500  * the program.
501  *
502  * Act as determined by the current "malfunction handler" which may have
503  * been specified by a call to svn_error_set_malfunction_handler() or else
504  * is the default handler as specified in that function's documentation. If
505  * the malfunction handler returns, then cause the function using this macro
506  * to return the error object that it generated.
507  *
508  * @note The intended use of this macro is where execution reaches a point
509  * that cannot possibly be reached unless there is a bug in the program.
510  *
511  * @since New in 1.6.
512  */
513 #define SVN_ERR_MALFUNCTION()                                      \
514   do {                                                             \
515     return svn_error_trace(svn_error__malfunction(                 \
516                                  TRUE, __FILE__, __LINE__, NULL)); \
517   } while (0)
518
519 /** Similar to SVN_ERR_MALFUNCTION(), but without the option of returning
520  * an error to the calling function.
521  *
522  * If possible you should use SVN_ERR_MALFUNCTION() instead.
523  *
524  * @since New in 1.6.
525  */
526 #define SVN_ERR_MALFUNCTION_NO_RETURN()                      \
527   do {                                                       \
528     svn_error__malfunction(FALSE, __FILE__, __LINE__, NULL); \
529     abort();                                                 \
530   } while (1)
531
532 /** Like SVN_ERR_ASSERT(), but append ERR to the returned error chain.
533  *
534  * If EXPR is false, return a malfunction error whose chain includes ERR.
535  * If EXPR is true, do nothing.  (In particular, this does not clear ERR.)
536  *
537  * Types: (svn_boolean_t expr, svn_error_t *err)
538  *
539  * @since New in 1.8.
540  */
541 #ifdef __clang_analyzer__
542 #include <assert.h>
543 /* Just ignore ERR.  If the assert triggers, it'll be our least concern. */
544 #define SVN_ERR_ASSERT_E(expr, err)       assert((expr))
545 #else
546 #define SVN_ERR_ASSERT_E(expr, err)                                      \
547   do {                                                                  \
548     if (!(expr)) {                                                      \
549       return svn_error_compose_create(                                  \
550                svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr), \
551                (err));                                                  \
552     }                                                                   \
553   } while (0)
554 #endif
555
556
557 /** Check that a condition is true: if not, report an error and possibly
558  * terminate the program.
559  *
560  * If the Boolean expression @a expr is true, do nothing. Otherwise,
561  * act as determined by the current "malfunction handler" which may have
562  * been specified by a call to svn_error_set_malfunction_handler() or else
563  * is the default handler as specified in that function's documentation. If
564  * the malfunction handler returns, then cause the function using this macro
565  * to return the error object that it generated.
566  *
567  * @note The intended use of this macro is to check a condition that cannot
568  * possibly be false unless there is a bug in the program.
569  *
570  * @note The condition to be checked should not be computationally expensive
571  * if it is reached often, as, unlike traditional "assert" statements, the
572  * evaluation of this expression is not compiled out in release-mode builds.
573  *
574  * @since New in 1.6.
575  *
576  * @see SVN_ERR_ASSERT_E()
577  */
578 #ifdef __clang_analyzer__
579 #include <assert.h>
580 #define SVN_ERR_ASSERT(expr)       assert((expr))
581 #else
582 #define SVN_ERR_ASSERT(expr)                                            \
583   do {                                                                  \
584     if (!(expr))                                                        \
585       SVN_ERR(svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr)); \
586   } while (0)
587 #endif
588
589 /** Similar to SVN_ERR_ASSERT(), but without the option of returning
590  * an error to the calling function.
591  *
592  * If possible you should use SVN_ERR_ASSERT() instead.
593  *
594  * @since New in 1.6.
595  */
596 #define SVN_ERR_ASSERT_NO_RETURN(expr)                          \
597   do {                                                          \
598     if (!(expr)) {                                              \
599       svn_error__malfunction(FALSE, __FILE__, __LINE__, #expr); \
600       abort();                                                  \
601     }                                                           \
602   } while (0)
603
604 /** Report a "Not implemented" malfunction.  Internal use only. */
605 #define SVN__NOT_IMPLEMENTED() \
606   return svn_error__malfunction(TRUE, __FILE__, __LINE__, "Not implemented.")
607
608 /** A helper function for the macros that report malfunctions. Handle a
609  * malfunction by calling the current "malfunction handler" which may have
610  * been specified by a call to svn_error_set_malfunction_handler() or else
611  * is the default handler as specified in that function's documentation.
612  *
613  * Pass all of the parameters to the handler. The error occurred in the
614  * source file @a file at line @a line, and was an assertion failure of the
615  * expression @a expr, or, if @a expr is null, an unconditional error.
616  *
617  * If @a can_return is true, the handler can return an error object
618  * that is returned by the caller. If @a can_return is false the
619  * method should never return. (The caller will call abort())
620  *
621  * @since New in 1.6.
622  */
623 svn_error_t *
624 svn_error__malfunction(svn_boolean_t can_return,
625                        const char *file,
626                        int line,
627                        const char *expr);
628
629 /** A type of function that handles an assertion failure or other internal
630  * malfunction detected within the Subversion libraries.
631  *
632  * The error occurred in the source file @a file at line @a line, and was an
633  * assertion failure of the expression @a expr, or, if @a expr is null, an
634  * unconditional error.
635  *
636  * If @a can_return is false a function of this type must never return.
637  *
638  * If @a can_return is true a function of this type must do one of:
639  *   - Return an error object describing the error, using an error code in
640  *     the category SVN_ERR_MALFUNC_CATEGORY_START.
641  *   - Never return.
642  *
643  * The function may alter its behaviour according to compile-time
644  * and run-time and even interactive conditions.
645  *
646  * @see SVN_ERROR_IN_CATEGORY()
647  *
648  * @since New in 1.6.
649  */
650 typedef svn_error_t *(*svn_error_malfunction_handler_t)
651   (svn_boolean_t can_return, const char *file, int line, const char *expr);
652
653 /** Cause subsequent malfunctions to be handled by @a func.
654  * Return the handler that was previously in effect.
655  *
656  * @a func may not be null.
657  *
658  * @note The default handler is svn_error_abort_on_malfunction().
659  *
660  * @note This function must be called in a single-threaded context.
661  *
662  * @since New in 1.6.
663  */
664 svn_error_malfunction_handler_t
665 svn_error_set_malfunction_handler(svn_error_malfunction_handler_t func);
666
667 /** Return the malfunction handler that is currently in effect.
668  * @since New in 1.9. */
669 svn_error_malfunction_handler_t
670 svn_error_get_malfunction_handler(void);
671
672 /** Handle a malfunction by returning an error object that describes it.
673  *
674  * When @a can_return is false, abort()
675  *
676  * This function implements @c svn_error_malfunction_handler_t.
677  *
678  * @since New in 1.6.
679  */
680 svn_error_t *
681 svn_error_raise_on_malfunction(svn_boolean_t can_return,
682                                const char *file,
683                                int line,
684                                const char *expr);
685
686 /** Handle a malfunction by printing a message to stderr and aborting.
687  *
688  * This function implements @c svn_error_malfunction_handler_t.
689  *
690  * @since New in 1.6.
691  */
692 svn_error_t *
693 svn_error_abort_on_malfunction(svn_boolean_t can_return,
694                                const char *file,
695                                int line,
696                                const char *expr);
697
698 /** @} */
699
700
701 #ifdef __cplusplus
702 }
703 #endif /* __cplusplus */
704
705 #endif /* SVN_ERROR_H */