]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/subversion/subversion/include/svn_error.h
Update svn-1.9.7 to 1.10.0.
[FreeBSD/FreeBSD.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 /** If @a child is SVN_NO_ERROR, return SVN_NO_ERROR.
169  * Else, prepend a new error to the error chain of @a child. The new error
170  * uses @a new_msg as error message but all other error attributes (such
171  * as the error code) are copied from @a child.
172  */
173 svn_error_t *
174 svn_error_quick_wrap(svn_error_t *child,
175                      const char *new_msg);
176
177 /** Like svn_error_quick_wrap(), but with format string support.
178  *
179  * @since New in 1.9.
180  */
181 svn_error_t *
182 svn_error_quick_wrapf(svn_error_t *child,
183                       const char *fmt,
184                       ...)
185        __attribute__((format(printf, 2, 3)));
186
187 /** Compose two errors, returning the composition as a brand new error
188  * and consuming the original errors.  Either or both of @a err1 and
189  * @a err2 may be @c SVN_NO_ERROR.  If both are not @c SVN_NO_ERROR,
190  * @a err2 will follow @a err1 in the chain of the returned error.
191  *
192  * Either @a err1 or @a err2 can be functions that return svn_error_t*
193  * but if both are functions they can be evaluated in either order as
194  * per the C language rules.
195  *
196  * @since New in 1.6.
197  */
198 svn_error_t *
199 svn_error_compose_create(svn_error_t *err1,
200                          svn_error_t *err2);
201
202 /** Add @a new_err to the end of @a chain's chain of errors.  The @a new_err
203  * chain will be copied into @a chain's pool and destroyed, so @a new_err
204  * itself becomes invalid after this function.
205  *
206  * Either @a chain or @a new_err can be functions that return svn_error_t*
207  * but if both are functions they can be evaluated in either order as
208  * per the C language rules.
209  */
210 void
211 svn_error_compose(svn_error_t *chain,
212                   svn_error_t *new_err);
213
214 /** Return the root cause of @a err by finding the last error in its
215  * chain (e.g. it or its children).  @a err may be @c SVN_NO_ERROR, in
216  * which case @c SVN_NO_ERROR is returned.  The returned error should
217  * @em not be cleared as it shares memory with @a err.
218  *
219  * @since New in 1.5.
220  */
221 svn_error_t *
222 svn_error_root_cause(svn_error_t *err);
223
224 /** Return the first error in @a err's chain that has an error code @a
225  * apr_err or #SVN_NO_ERROR if there is no error with that code.  The
226  * returned error should @em not be cleared as it shares memory with @a err.
227  *
228  * If @a err is #SVN_NO_ERROR, return #SVN_NO_ERROR.
229  *
230  * @since New in 1.7.
231  */
232 svn_error_t *
233 svn_error_find_cause(svn_error_t *err, apr_status_t apr_err);
234
235 /** Create a new error that is a deep copy of @a err and return it.
236  *
237  * @since New in 1.2.
238  */
239 svn_error_t *
240 svn_error_dup(const svn_error_t *err);
241
242 /** Free the memory used by @a error, as well as all ancestors and
243  * descendants of @a error.
244  *
245  * Unlike other Subversion objects, errors are managed explicitly; you
246  * MUST clear an error if you are ignoring it, or you are leaking memory.
247  * For convenience, @a error may be @c NULL, in which case this function does
248  * nothing; thus, svn_error_clear(svn_foo(...)) works as an idiom to
249  * ignore errors.
250  */
251 void
252 svn_error_clear(svn_error_t *error);
253
254
255 #if defined(SVN_ERR__TRACING)
256 /** Set the error location for debug mode. */
257 void
258 svn_error__locate(const char *file,
259                   long line);
260
261 /* Wrapper macros to collect file and line information */
262 #define svn_error_create \
263   (svn_error__locate(__FILE__,__LINE__), (svn_error_create))
264 #define svn_error_createf \
265   (svn_error__locate(__FILE__,__LINE__), (svn_error_createf))
266 #define svn_error_wrap_apr \
267   (svn_error__locate(__FILE__,__LINE__), (svn_error_wrap_apr))
268 #define svn_error_quick_wrap \
269   (svn_error__locate(__FILE__,__LINE__), (svn_error_quick_wrap))
270 #define svn_error_quick_wrapf \
271   (svn_error__locate(__FILE__,__LINE__), (svn_error_quick_wrapf))
272 #endif
273
274
275 /**
276  * Very basic default error handler: print out error stack @a error to the
277  * stdio stream @a stream, with each error prefixed by @a prefix; quit and
278  * clear @a error iff the @a fatal flag is set.  Allocations are performed
279  * in the @a error's pool.
280  *
281  * If you're not sure what prefix to pass, just pass "svn: ".  That's
282  * what code that used to call svn_handle_error() and now calls
283  * svn_handle_error2() does.
284  *
285  * Note that this should only be used from commandline specific code, or
286  * code that knows that @a stream is really where the application wants
287  * to receive its errors on.
288  *
289  * @since New in 1.2.
290  */
291 void
292 svn_handle_error2(svn_error_t *error,
293                   FILE *stream,
294                   svn_boolean_t fatal,
295                   const char *prefix);
296
297 /** Like svn_handle_error2() but with @c prefix set to "svn: "
298  *
299  * @deprecated Provided for backward compatibility with the 1.1 API.
300  */
301 SVN_DEPRECATED
302 void
303 svn_handle_error(svn_error_t *error,
304                  FILE *stream,
305                  svn_boolean_t fatal);
306
307 /**
308  * Very basic default warning handler: print out the error @a error to the
309  * stdio stream @a stream, prefixed by @a prefix.  Allocations are
310  * performed in the error's pool.
311  *
312  * @a error may not be @c NULL.
313  *
314  * @note This does not clear @a error.
315  *
316  * @since New in 1.2.
317  */
318 void
319 svn_handle_warning2(FILE *stream,
320                     const svn_error_t *error,
321                     const char *prefix);
322
323 /** Like svn_handle_warning2() but with @c prefix set to "svn: "
324  *
325  * @deprecated Provided for backward compatibility with the 1.1 API.
326  */
327 SVN_DEPRECATED
328 void
329 svn_handle_warning(FILE *stream,
330                    svn_error_t *error);
331
332
333 /** A statement macro for checking error values.
334  *
335  * Evaluate @a expr.  If it yields an error, return that error from the
336  * current function.  Otherwise, continue.
337  *
338  * The <tt>do { ... } while (0)</tt> wrapper has no semantic effect,
339  * but it makes this macro syntactically equivalent to the expression
340  * statement it resembles.  Without it, statements like
341  *
342  * @code
343  *   if (a)
344  *     SVN_ERR(some operation);
345  *   else
346  *     foo;
347  * @endcode
348  *
349  * would not mean what they appear to.
350  */
351 #define SVN_ERR(expr)                           \
352   do {                                          \
353     svn_error_t *svn_err__temp = (expr);        \
354     if (svn_err__temp)                          \
355       return svn_error_trace(svn_err__temp);    \
356   } while (0)
357
358 /**
359  * A macro for wrapping an error in a source-location trace message.
360  *
361  * This macro can be used when directly returning an already created
362  * error (when not using SVN_ERR, svn_error_create(), etc.) to ensure
363  * that the call stack is recorded correctly.
364  *
365  * @since New in 1.7.
366  */
367 #ifdef SVN_ERR__TRACING
368 svn_error_t *
369 svn_error__trace(const char *file, long line, svn_error_t *err);
370
371 #define svn_error_trace(expr)  svn_error__trace(__FILE__, __LINE__, (expr))
372 #else
373 #define svn_error_trace(expr)  (expr)
374 #endif
375
376 /**
377  * Returns an error chain that is based on @a err's error chain but
378  * does not include any error tracing placeholders.  @a err is not
379  * modified, except for any allocations using its pool.
380  *
381  * The returned error chain is allocated from @a err's pool and shares
382  * its message and source filename character arrays.  The returned
383  * error chain should *not* be cleared because it is not a fully
384  * fledged error chain, only clearing @a err should be done to clear
385  * the returned error chain.  If @a err is cleared, then the returned
386  * error chain is unusable.
387  *
388  * @a err can be #SVN_NO_ERROR.  If @a err is not #SVN_NO_ERROR, then
389  * the last link in the error chain must be a non-tracing error, i.e,
390  * a real error.
391  *
392  * @since New in 1.7.
393  */
394 svn_error_t *svn_error_purge_tracing(svn_error_t *err);
395
396
397 /** A statement macro, very similar to @c SVN_ERR.
398  *
399  * This macro will wrap the error with the specified text before
400  * returning the error.
401  */
402 #define SVN_ERR_W(expr, wrap_msg)                           \
403   do {                                                      \
404     svn_error_t *svn_err__temp = (expr);                    \
405     if (svn_err__temp)                                      \
406       return svn_error_quick_wrap(svn_err__temp, wrap_msg); \
407   } while (0)
408
409
410 /** A statement macro intended for the main() function of the 'svn' program.
411  *
412  * Evaluate @a expr. If it yields an error, display the error on stdout
413  * and return @c EXIT_FAILURE.
414  *
415  * @note Not for use in the library, as it prints to stderr. This macro
416  * no longer suits the needs of the 'svn' program, and is not generally
417  * suitable for third-party use as it assumes the program name is 'svn'.
418  *
419  * @deprecated Provided for backward compatibility with the 1.8 API. Consider
420  * using svn_handle_error2() or svn_cmdline_handle_exit_error() instead.
421  */
422 #define SVN_INT_ERR(expr)                                        \
423   do {                                                           \
424     svn_error_t *svn_err__temp = (expr);                         \
425     if (svn_err__temp) {                                         \
426       svn_handle_error2(svn_err__temp, stderr, FALSE, "svn: ");  \
427       svn_error_clear(svn_err__temp);                            \
428       return EXIT_FAILURE; }                                     \
429   } while (0)
430
431 /** @} */
432
433 \f
434 /** Error groups
435  *
436  * @defgroup svn_error_error_groups Error groups
437  * @{
438  */
439
440 /**
441  * Return TRUE if @a err is an error specifically related to locking a
442  * path in the repository, FALSE otherwise.
443  *
444  * SVN_ERR_FS_OUT_OF_DATE and SVN_ERR_FS_NOT_FOUND are in here because it's a
445  * non-fatal error that can be thrown when attempting to lock an item.
446  *
447  * SVN_ERR_REPOS_HOOK_FAILURE refers to the pre-lock hook.
448  *
449  * @since New in 1.2.
450  */
451 #define SVN_ERR_IS_LOCK_ERROR(err)                          \
452   (err->apr_err == SVN_ERR_FS_PATH_ALREADY_LOCKED ||        \
453    err->apr_err == SVN_ERR_FS_NOT_FOUND           ||        \
454    err->apr_err == SVN_ERR_FS_OUT_OF_DATE         ||        \
455    err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN      ||        \
456    err->apr_err == SVN_ERR_REPOS_HOOK_FAILURE     ||        \
457    err->apr_err == SVN_ERR_FS_NO_SUCH_REVISION    ||        \
458    err->apr_err == SVN_ERR_FS_OUT_OF_DATE         ||        \
459    err->apr_err == SVN_ERR_FS_NOT_FILE)
460
461 /**
462  * Return TRUE if @a err is an error specifically related to unlocking
463  * a path in the repository, FALSE otherwise.
464  *
465  * SVN_ERR_REPOS_HOOK_FAILURE refers to the pre-unlock hook.
466  *
467  * @since New in 1.2.
468  */
469 #define SVN_ERR_IS_UNLOCK_ERROR(err)                        \
470   (err->apr_err == SVN_ERR_FS_PATH_NOT_LOCKED ||            \
471    err->apr_err == SVN_ERR_FS_BAD_LOCK_TOKEN ||             \
472    err->apr_err == SVN_ERR_FS_LOCK_OWNER_MISMATCH ||        \
473    err->apr_err == SVN_ERR_FS_NO_SUCH_LOCK ||               \
474    err->apr_err == SVN_ERR_RA_NOT_LOCKED ||                 \
475    err->apr_err == SVN_ERR_FS_LOCK_EXPIRED ||               \
476    err->apr_err == SVN_ERR_REPOS_HOOK_FAILURE)
477
478 /** Evaluates to @c TRUE iff @a apr_err (of type apr_status_t) is in the given
479  * @a category, which should be one of the @c SVN_ERR_*_CATEGORY_START
480  * constants.
481  *
482  * @since New in 1.7.
483  */
484 #define SVN_ERROR_IN_CATEGORY(apr_err, category)            \
485     ((category) == ((apr_err) / SVN_ERR_CATEGORY_SIZE) * SVN_ERR_CATEGORY_SIZE)
486
487
488 /** @} */
489
490 \f
491 /** Internal malfunctions and assertions
492  *
493  * @defgroup svn_error_malfunction_assertion Malfunctions and assertions
494  * @{
495  */
496
497 /** Report that an internal malfunction has occurred, and possibly terminate
498  * the program.
499  *
500  * Act as determined by the current "malfunction handler" which may have
501  * been specified by a call to svn_error_set_malfunction_handler() or else
502  * is the default handler as specified in that function's documentation. If
503  * the malfunction handler returns, then cause the function using this macro
504  * to return the error object that it generated.
505  *
506  * @note The intended use of this macro is where execution reaches a point
507  * that cannot possibly be reached unless there is a bug in the program.
508  *
509  * @since New in 1.6.
510  */
511 #define SVN_ERR_MALFUNCTION()                                      \
512   do {                                                             \
513     return svn_error_trace(svn_error__malfunction(                 \
514                                  TRUE, __FILE__, __LINE__, NULL)); \
515   } while (0)
516
517 /** Similar to SVN_ERR_MALFUNCTION(), but without the option of returning
518  * an error to the calling function.
519  *
520  * If possible you should use SVN_ERR_MALFUNCTION() instead.
521  *
522  * @since New in 1.6.
523  */
524 #define SVN_ERR_MALFUNCTION_NO_RETURN()                      \
525   do {                                                       \
526     svn_error__malfunction(FALSE, __FILE__, __LINE__, NULL); \
527     abort();                                                 \
528   } while (1)
529
530 /** Like SVN_ERR_ASSERT(), but append ERR to the returned error chain.
531  *
532  * If EXPR is false, return a malfunction error whose chain includes ERR.
533  * If EXPR is true, do nothing.  (In particular, this does not clear ERR.)
534  *
535  * Types: (svn_boolean_t expr, svn_error_t *err)
536  *
537  * @since New in 1.8.
538  */
539 #ifdef __clang_analyzer__
540 #include <assert.h>
541 /* Just ignore ERR.  If the assert triggers, it'll be our least concern. */
542 #define SVN_ERR_ASSERT_E(expr, err)       assert((expr))
543 #else
544 #define SVN_ERR_ASSERT_E(expr, err)                                      \
545   do {                                                                  \
546     if (!(expr)) {                                                      \
547       return svn_error_compose_create(                                  \
548                svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr), \
549                (err));                                                  \
550     }                                                                   \
551   } while (0)
552 #endif
553
554
555 /** Check that a condition is true: if not, report an error and possibly
556  * terminate the program.
557  *
558  * If the Boolean expression @a expr is true, do nothing. Otherwise,
559  * act as determined by the current "malfunction handler" which may have
560  * been specified by a call to svn_error_set_malfunction_handler() or else
561  * is the default handler as specified in that function's documentation. If
562  * the malfunction handler returns, then cause the function using this macro
563  * to return the error object that it generated.
564  *
565  * @note The intended use of this macro is to check a condition that cannot
566  * possibly be false unless there is a bug in the program.
567  *
568  * @note The condition to be checked should not be computationally expensive
569  * if it is reached often, as, unlike traditional "assert" statements, the
570  * evaluation of this expression is not compiled out in release-mode builds.
571  *
572  * @since New in 1.6.
573  *
574  * @see SVN_ERR_ASSERT_E()
575  */
576 #ifdef __clang_analyzer__
577 #include <assert.h>
578 #define SVN_ERR_ASSERT(expr)       assert((expr))
579 #else
580 #define SVN_ERR_ASSERT(expr)                                            \
581   do {                                                                  \
582     if (!(expr))                                                        \
583       SVN_ERR(svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr)); \
584   } while (0)
585 #endif
586
587 /** Similar to SVN_ERR_ASSERT(), but without the option of returning
588  * an error to the calling function.
589  *
590  * If possible you should use SVN_ERR_ASSERT() instead.
591  *
592  * @since New in 1.6.
593  */
594 #define SVN_ERR_ASSERT_NO_RETURN(expr)                          \
595   do {                                                          \
596     if (!(expr)) {                                              \
597       svn_error__malfunction(FALSE, __FILE__, __LINE__, #expr); \
598       abort();                                                  \
599     }                                                           \
600   } while (0)
601
602 /** Report a "Not implemented" malfunction.  Internal use only. */
603 #define SVN__NOT_IMPLEMENTED() \
604   return svn_error__malfunction(TRUE, __FILE__, __LINE__, "Not implemented.")
605
606 /** A helper function for the macros that report malfunctions. Handle a
607  * malfunction by calling the current "malfunction handler" which may have
608  * been specified by a call to svn_error_set_malfunction_handler() or else
609  * is the default handler as specified in that function's documentation.
610  *
611  * Pass all of the parameters to the handler. The error occurred in the
612  * source file @a file at line @a line, and was an assertion failure of the
613  * expression @a expr, or, if @a expr is null, an unconditional error.
614  *
615  * If @a can_return is true, the handler can return an error object
616  * that is returned by the caller. If @a can_return is false the
617  * method should never return. (The caller will call abort())
618  *
619  * @since New in 1.6.
620  */
621 svn_error_t *
622 svn_error__malfunction(svn_boolean_t can_return,
623                        const char *file,
624                        int line,
625                        const char *expr);
626
627 /** A type of function that handles an assertion failure or other internal
628  * malfunction detected within the Subversion libraries.
629  *
630  * The error occurred in the source file @a file at line @a line, and was an
631  * assertion failure of the expression @a expr, or, if @a expr is null, an
632  * unconditional error.
633  *
634  * If @a can_return is false a function of this type must never return.
635  *
636  * If @a can_return is true a function of this type must do one of:
637  *   - Return an error object describing the error, using an error code in
638  *     the category SVN_ERR_MALFUNC_CATEGORY_START.
639  *   - Never return.
640  *
641  * The function may alter its behaviour according to compile-time
642  * and run-time and even interactive conditions.
643  *
644  * @see SVN_ERROR_IN_CATEGORY()
645  *
646  * @since New in 1.6.
647  */
648 typedef svn_error_t *(*svn_error_malfunction_handler_t)
649   (svn_boolean_t can_return, const char *file, int line, const char *expr);
650
651 /** Cause subsequent malfunctions to be handled by @a func.
652  * Return the handler that was previously in effect.
653  *
654  * @a func may not be null.
655  *
656  * @note The default handler is svn_error_abort_on_malfunction().
657  *
658  * @note This function must be called in a single-threaded context.
659  *
660  * @since New in 1.6.
661  */
662 svn_error_malfunction_handler_t
663 svn_error_set_malfunction_handler(svn_error_malfunction_handler_t func);
664
665 /** Return the malfunction handler that is currently in effect.
666  * @since New in 1.9. */
667 svn_error_malfunction_handler_t
668 svn_error_get_malfunction_handler(void);
669
670 /** Handle a malfunction by returning an error object that describes it.
671  *
672  * When @a can_return is false, abort()
673  *
674  * This function implements @c svn_error_malfunction_handler_t.
675  *
676  * @since New in 1.6.
677  */
678 svn_error_t *
679 svn_error_raise_on_malfunction(svn_boolean_t can_return,
680                                const char *file,
681                                int line,
682                                const char *expr);
683
684 /** Handle a malfunction by printing a message to stderr and aborting.
685  *
686  * This function implements @c svn_error_malfunction_handler_t.
687  *
688  * @since New in 1.6.
689  */
690 svn_error_t *
691 svn_error_abort_on_malfunction(svn_boolean_t can_return,
692                                const char *file,
693                                int line,
694                                const char *expr);
695
696 /** @} */
697
698
699 #ifdef __cplusplus
700 }
701 #endif /* __cplusplus */
702
703 #endif /* SVN_ERROR_H */