]>
git.proxmox.com Git - libgit2.git/blob - src/libgit2/errors.h
2 * Copyright (C) the libgit2 contributors. All rights reserved.
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
8 #ifndef INCLUDE_errors_h__
9 #define INCLUDE_errors_h__
14 * `vprintf`-style formatting for the error message for this thread.
16 void git_error_vset(int error_class
, const char *fmt
, va_list ap
);
19 * Set error message for user callback if needed.
21 * If the error code in non-zero and no error message is set, this
22 * sets a generic error message.
24 * @return This always returns the `error_code` parameter.
26 GIT_INLINE(int) git_error_set_after_callback_function(
27 int error_code
, const char *action
)
30 const git_error
*e
= git_error_last();
31 if (!e
|| !e
->message
)
32 git_error_set(e
? e
->klass
: GIT_ERROR_CALLBACK
,
33 "%s callback returned %d", action
, error_code
);
39 #define git_error_set_after_callback(code) \
40 git_error_set_after_callback_function((code), __FUNCTION__)
42 #define git_error_set_after_callback(code) \
43 git_error_set_after_callback_function((code), __func__)
47 * Gets the system error code for this thread.
49 int git_error_system_last(void);
52 * Sets the system error code for this thread.
54 void git_error_system_set(int code
);
57 * Structure to preserve libgit2 error state
66 * Capture current error state to restore later, returning error code.
67 * If `error_code` is zero, this does not clear the current error state.
68 * You must either restore this error state, or free it.
70 extern int git_error_state_capture(git_error_state
*state
, int error_code
);
73 * Restore error state to a previous value, returning saved error code.
75 extern int git_error_state_restore(git_error_state
*state
);
77 /** Free an error state. */
78 extern void git_error_state_free(git_error_state
*state
);