blob: 1b27e0fd2d7d5c7e12d851bf05fe2f09498218dd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/**
* @file
* @brief Handling of error conditions that are not program bugs.
**/
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include "AppHdr.h"
#include "errors.h"
#include "strings.h"
NORETURN void fail(const char *msg, ...)
{
va_list args;
va_start(args, msg);
string buf = vmake_stringf(msg, args);
va_end(args);
// Do we want to call end() right on when there's no one trying catching,
// or should we risk exception code mess things up?
throw ext_fail_exception(buf);
}
NORETURN void sysfail(const char *msg, ...)
{
va_list args;
va_start(args, msg);
string buf = vmake_stringf(msg, args);
va_end(args);
buf += ": ";
buf += strerror(errno);
throw ext_fail_exception(buf);
}
NORETURN void corrupted(const char *msg, ...)
{
va_list args;
va_start(args, msg);
string buf = vmake_stringf(msg, args);
va_end(args);
throw corrupted_save(buf);
}
|