File: except.c

package info (click to toggle)
pmidi 1.4.1-2.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 244 kB
  • ctags: 637
  • sloc: ansic: 2,908; makefile: 70
file content (58 lines) | stat: -rw-r--r-- 1,381 bytes parent folder | download | duplicates (8)
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
48
49
50
51
52
53
54
55
56
57
58
/*
 * 
 * except.m - error handling code
 * 
 * Copyright (C) 1999 Steve Ratcliffe
 * 
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License version 2 as
 *  published by the Free Software Foundation.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 */


#include "glib.h"
#include "elements.h"
#include "except.h"
#include "intl.h"

#include <stdarg.h>
#include "stdio.h"


static struct except format;
static struct except io;
static struct except debug;

struct except *formatError = &format;	/* Bad file format */
struct except *ioError = &io;	/* I/o error to file */
struct except *debugError = &debug;	/* Debugging 'shouldn't happen' errors */

/*
 * Deal with errors. At present just exit, will allow error
 * recovery in the future.
 *  Arguments:
 *    e         - Exception thrown
 *    message   - Message
 *              - Takes variable number of arguments
 */
void 
except(struct except *e, char *message, ...)
{
	va_list ap;

	va_start(ap, message);
	vfprintf(stderr, message, ap);
	va_end(ap);
	putc('\n', stderr);

#ifdef DEBUG
	g_on_error_stack_trace("a.out");
#endif
	exit(1);
}