Debian Codegraph @

src/except.c

raw symbols SCIP
1 /*
2 *
3 * except.m - error handling code
4 *
5 * Copyright (C) 1999 Steve Ratcliffe
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17
18 #include "glib.h"
19 #include "elements.h"
20 #include "except.h"
21 #include "intl.h"
22
23 #include <stdarg.h>
24 #include "stdio.h"
25
26
27 static struct except format;
28 static struct except io;
29 static struct except debug;
30
31 struct except *formatError = &format; /* Bad file format */
32 struct except *ioError = &io; /* I/o error to file */
33 struct except *debugError = &debug; /* Debugging 'shouldn't happen' errors */
34
35 /*
36 * Deal with errors. At present just exit, will allow error
37 * recovery in the future.
38 * Arguments:
39 * e - Exception thrown
40 * message - Message
41 * - Takes variable number of arguments
42 */
43 void
44 except(struct except *e, char *message, ...)
45 {
46 va_list ap;
47
48 va_start(ap, message);
49 vfprintf(stderr, message, ap);
50 va_end(ap);
51 putc('\n', stderr);
52
53 #ifdef DEBUG
54 g_on_error_stack_trace("a.out");
55 #endif
56 exit(1);
57 }
58