| 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"cxx . . $ `<file>/src/glib.h`/ |
| 19 | #include "elements.h"cxx . . $ `<file>/src/elements.h`/ |
| 20 | #include "except.h"cxx . . $ `<file>/src/except.h`/ |
| 21 | #include "intl.h"cxx . . $ `<file>/src/intl.h`/ |
| 22 | |
| 23 | #include <stdarg.h> |
| 24 | #include "stdio.h" |
| 25 | |
| 26 | |
| 27 | static struct exceptcxx . . $ except# formatcxx . . $ format.; |
| 28 | static struct exceptcxx . . $ except# iocxx . . $ io.; |
| 29 | static struct exceptcxx . . $ except# debugcxx . . $ debug.; |
| 30 | |
| 31 | struct exceptcxx . . $ except# *formatErrorcxx . . $ formatError. = &formatcxx . . $ format.; /* Bad file format */ |
| 32 | struct exceptcxx . . $ except# *ioErrorcxx . . $ ioError. = &iocxx . . $ io.; /* I/o error to file */ |
| 33 | struct exceptcxx . . $ except# *debugErrorcxx . . $ debugError. = &debugcxx . . $ 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 | exceptcxx . . $ except(af5967826b8ba103).(struct exceptcxx . . $ except# *e, char *message, ...) |
| 45 | { |
| 46 | va_listcxx . . $ va_list# ap; |
| 47 | |
| 48 | va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`!(ap, message); |
| 49 | vfprintfcxx . . $ vfprintf(bded311e54d67f9c).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, message, ap); |
| 50 | va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`!(ap); |
| 51 | putccxx . . $ putc(b1cd03d6c470d1bd).('\n', stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); |
| 52 | |
| 53 | #ifdef DEBUG |
| 54 | g_on_error_stack_trace("a.out"); |
| 55 | #endif |
| 56 | exitcxx . . $ exit(3ca292c338df9bb3).(1); |
| 57 | } |
| 58 |