Merge branch 'ab/usage-error-docs'

Documentation updates, with unrelated comment updates, too.

* ab/usage-error-docs:
  api docs: document that BUG() emits a trace2 error event
  api docs: document BUG() in api-error-handling.txt
  usage.c: don't copy/paste the same comment three times
This commit is contained in:
Junio C Hamano 2021-04-20 17:23:36 -07:00
commit fdef940afe
3 changed files with 14 additions and 15 deletions

View File

@ -1,8 +1,11 @@
Error reporting in git Error reporting in git
====================== ======================
`die`, `usage`, `error`, and `warning` report errors of various `BUG`, `die`, `usage`, `error`, and `warning` report errors of
kinds. various kinds.
- `BUG` is for failed internal assertions that should never happen,
i.e. a bug in git itself.
- `die` is for fatal application errors. It prints a message to - `die` is for fatal application errors. It prints a message to
the user and exits with status 128. the user and exits with status 128.
@ -20,6 +23,9 @@ kinds.
without running into too many problems. Like `error`, it without running into too many problems. Like `error`, it
returns -1 after reporting the situation to the caller. returns -1 after reporting the situation to the caller.
These reports will be logged via the trace2 facility. See the "error"
event in link:api-trace2.txt[trace2 API].
Customizable error handlers Customizable error handlers
--------------------------- ---------------------------

View File

@ -465,7 +465,7 @@ completed.)
------------ ------------
`"error"`:: `"error"`::
This event is emitted when one of the `error()`, `die()`, This event is emitted when one of the `BUG()`, `error()`, `die()`,
`warning()`, or `usage()` functions are called. `warning()`, or `usage()` functions are called.
+ +
------------ ------------

17
usage.c
View File

@ -55,12 +55,13 @@ static NORETURN void usage_builtin(const char *err, va_list params)
exit(129); exit(129);
} }
/*
* We call trace2_cmd_error_va() in the below functions first and
* expect it to va_copy 'params' before using it (because an 'ap' can
* only be walked once).
*/
static NORETURN void die_builtin(const char *err, va_list params) static NORETURN void die_builtin(const char *err, va_list params)
{ {
/*
* We call this trace2 function first and expect it to va_copy 'params'
* before using it (because an 'ap' can only be walked once).
*/
trace2_cmd_error_va(err, params); trace2_cmd_error_va(err, params);
vreportf("fatal: ", err, params); vreportf("fatal: ", err, params);
@ -70,10 +71,6 @@ static NORETURN void die_builtin(const char *err, va_list params)
static void error_builtin(const char *err, va_list params) static void error_builtin(const char *err, va_list params)
{ {
/*
* We call this trace2 function first and expect it to va_copy 'params'
* before using it (because an 'ap' can only be walked once).
*/
trace2_cmd_error_va(err, params); trace2_cmd_error_va(err, params);
vreportf("error: ", err, params); vreportf("error: ", err, params);
@ -81,10 +78,6 @@ static void error_builtin(const char *err, va_list params)
static void warn_builtin(const char *warn, va_list params) static void warn_builtin(const char *warn, va_list params)
{ {
/*
* We call this trace2 function first and expect it to va_copy 'params'
* before using it (because an 'ap' can only be walked once).
*/
trace2_cmd_error_va(warn, params); trace2_cmd_error_va(warn, params);
vreportf("warning: ", warn, params); vreportf("warning: ", warn, params);