222
|
1 // error.cc -*- C++ -*- |
|
2 /* |
|
3 |
1011
|
4 Copyright (C) 1992, 1993, 1994, 1995 John W. Eaton |
222
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
238
|
24 #ifdef HAVE_CONFIG_H |
1192
|
25 #include <config.h> |
222
|
26 #endif |
|
27 |
|
28 #include <stdio.h> |
|
29 #include <stdlib.h> |
|
30 #include <stdarg.h> |
|
31 |
227
|
32 #include "lo-error.h" |
222
|
33 |
|
34 liboctave_error_handler current_liboctave_error_handler = liboctave_fatal; |
|
35 |
|
36 static void |
|
37 verror (const char *name, const char *fmt, va_list args) |
|
38 { |
533
|
39 if (name) |
222
|
40 fprintf (stderr, "%s: ", name); |
|
41 |
|
42 vfprintf (stderr, fmt, args); |
|
43 fprintf (stderr, "\n"); |
|
44 fflush (stderr); |
|
45 } |
|
46 |
|
47 void |
|
48 set_liboctave_error_handler (liboctave_error_handler f) |
|
49 { |
|
50 if (f) |
|
51 current_liboctave_error_handler = f; |
|
52 else |
227
|
53 current_liboctave_error_handler = liboctave_fatal; |
222
|
54 } |
|
55 |
|
56 void |
|
57 liboctave_fatal (const char *fmt, ...) |
|
58 { |
|
59 va_list args; |
|
60 va_start (args, fmt); |
|
61 verror ("fatal", fmt, args); |
|
62 va_end (args); |
|
63 |
|
64 exit (1); |
|
65 } |
|
66 |
|
67 /* |
|
68 ;;; Local Variables: *** |
|
69 ;;; mode: C++ *** |
|
70 ;;; page-delimiter: "^/\\*" *** |
|
71 ;;; End: *** |
|
72 */ |