| 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 |
|
541 |
static void fmt_error(int whichpass, asar_error_id errid, const char* fmt, va_list args) { |
| 13 |
3/6
✓ Branch 0 taken 541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 276 times.
✓ Branch 3 taken 265 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
541 |
assert(errid >= 0 && errid < error_id_end); |
| 14 |
|
|
|
| 15 |
|
276 |
char error_buffer[1024]; |
| 16 |
2/2
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 276 times.
|
541 |
vsnprintf(error_buffer, sizeof(error_buffer), fmt, args); |
| 17 |
|
|
|
| 18 |
1/2
✓ Branch 0 taken 541 times.
✗ Branch 1 not taken.
|
541 |
error_interface((int)errid, whichpass, error_buffer); |
| 19 |
|
541 |
} |
| 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 |
|
466 |
void asar_throw_error_impl_error_type_block(int whichpass, asar_error_id errid, const char* fmt, ...) { |
| 28 |
|
466 |
va_list args; va_start(args, fmt); |
| 29 |
1/2
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
|
466 |
fmt_error(whichpass, errid, fmt, args); |
| 30 |
|
466 |
va_end(args); |
| 31 |
|
466 |
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 |
|
456 |
const char* get_error_name(asar_error_id errid) |
| 47 |
|
|
{ |
| 48 |
3/4
✓ Branch 0 taken 456 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
✓ Branch 3 taken 226 times.
|
456 |
assert(errid >= 0 && errid < error_id_end); |
| 49 |
|
|
|
| 50 |
|
456 |
const asar_error_mapping& error = asar_all_errors[errid]; |
| 51 |
|
|
|
| 52 |
|
456 |
return error.name; |
| 53 |
|
|
} |
| 54 |
|
|
|