Line |
Branch |
Exec |
Source |
1 |
|
|
#include <cassert> |
2 |
|
|
#include <cstdarg> |
3 |
|
|
|
4 |
|
|
#include "std-includes.h" |
5 |
|
|
#include "errors.h" |
6 |
|
|
#include "interface-shared.h" |
7 |
|
|
|
8 |
|
|
#if defined(__clang__) || defined(__GNUC__) |
9 |
|
|
// silences the Wformat-nonliteral |
10 |
|
|
[[gnu::format(printf, 3, 0)]] |
11 |
|
|
#endif |
12 |
|
531 |
static void fmt_error(int whichpass, asar_error_id errid, const char* fmt, va_list args) { |
13 |
3/6
✓ Branch 0 taken 531 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 271 times.
✓ Branch 3 taken 260 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
531 |
assert(errid >= 0 && errid < error_id_end); |
14 |
|
|
|
15 |
|
271 |
char error_buffer[1024]; |
16 |
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 271 times.
|
531 |
vsnprintf(error_buffer, sizeof(error_buffer), fmt, args); |
17 |
|
|
|
18 |
1/2
✓ Branch 0 taken 531 times.
✗ Branch 1 not taken.
|
531 |
error_interface((int)errid, whichpass, error_buffer); |
19 |
|
531 |
} |
20 |
|
|
|
21 |
|
|
// this is uncomfortably much to copy paste,,, but whatever |
22 |
|
36 |
void asar_throw_error_impl_error_type_null(int whichpass, asar_error_id errid, const char* fmt, ...) { |
23 |
|
36 |
va_list args; va_start(args, fmt); |
24 |
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
|
36 |
fmt_error(whichpass, errid, fmt, args); |
25 |
|
36 |
va_end(args); |
26 |
|
36 |
} |
27 |
|
456 |
void asar_throw_error_impl_error_type_block(int whichpass, asar_error_id errid, const char* fmt, ...) { |
28 |
|
456 |
va_list args; va_start(args, fmt); |
29 |
1/2
✓ Branch 0 taken 456 times.
✗ Branch 1 not taken.
|
456 |
fmt_error(whichpass, errid, fmt, args); |
30 |
|
456 |
va_end(args); |
31 |
|
456 |
throw errblock{}; |
32 |
|
|
} |
33 |
|
31 |
void asar_throw_error_impl_error_type_line(int whichpass, asar_error_id errid, const char* fmt, ...) { |
34 |
|
31 |
va_list args; va_start(args, fmt); |
35 |
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
|
31 |
fmt_error(whichpass, errid, fmt, args); |
36 |
|
31 |
va_end(args); |
37 |
|
31 |
throw errline{}; |
38 |
|
|
} |
39 |
|
8 |
void asar_throw_error_impl_error_type_fatal(int whichpass, asar_error_id errid, const char* fmt, ...) { |
40 |
|
8 |
va_list args; va_start(args, fmt); |
41 |
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 |
fmt_error(whichpass, errid, fmt, args); |
42 |
|
8 |
va_end(args); |
43 |
|
8 |
throw errfatal{}; |
44 |
|
|
} |
45 |
|
|
|
46 |
|
444 |
const char* get_error_name(asar_error_id errid) |
47 |
|
|
{ |
48 |
3/4
✓ Branch 0 taken 444 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 224 times.
✓ Branch 3 taken 220 times.
|
444 |
assert(errid >= 0 && errid < error_id_end); |
49 |
|
|
|
50 |
|
444 |
const asar_error_mapping& error = asar_all_errors[errid]; |
51 |
|
|
|
52 |
|
444 |
return error.name; |
53 |
|
|
} |
54 |
|
|
|