1 /******************************************************************************
2   Error.c
3 
4   Change Control:                                                      DDMMYYYY
5     Michael Still    File created                                      03062000
6 
7   Purpose:
8     Panda can experience errors for many reasons. This file contains
9     centralised error handling code to make the programming easier and more
10     consistent elsewhere. The code should also handle all the platforms
11     the code is expected to run on correctly.
12 
13   Copyright (C) Michael Still 2000 - 2002
14 
15   This program is free software; you can redistribute it and/or modify
16   it under the terms of the GNU General Public License as published by
17   the Free Software Foundation; either version 2 of the License, or
18   (at your option) any later version.
19 
20   This program is distributed in the hope that it will be useful,
21   but WITHOUT ANY WARRANTY; without even the implied warranty of
22   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23   GNU General Public License for more details.
24 
25   You should have received a copy of the GNU General Public License
26   along with this program; if not, write to the Free Software
27   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 ******************************************************************************/
29 
30 #include <stdio.h>
31 #include <stdlib.h>
32 
33 #if defined _WINDOWS
34 #include "stdafx.h"
35 #include <windows.h>
36 #else
37 #include <panda/constants.h>
38 #include <panda/functions.h>
39 #endif
40 
41 /******************************************************************************
42 DOCBOOK START
43 
44 FUNCTION panda_error
45 PURPOSE handle a <command>Panda</command> error
46 
47 SYNOPSIS START
48 #include&lt;panda/constants.h&gt;
49 #include&lt;panda/functions.h&gt;
50 void panda_error (int fatal, char *msg);
51 SYNOPSIS END
52 
53 DESCRIPTION Print out the error message to stderr and then exit (if fatal is panda_true).
54 
55 RETURNS Nothing
56 
57 EXAMPLE START
58 #include&lt;panda/constants.h&gt;
59 #include&lt;panda/functions.h&gt;
60 
61 panda_error ("All is rotten in the state of Denmark");
62 EXAMPLE END
63 DOCBOOK END
64 ******************************************************************************/
65 
66 // You can bang or head or you can drown in a hole
67 //                                                    -- Vanessa Amarosi, Shine
68 void
panda_error(int fatal,char * message)69 panda_error (int fatal, char *message)
70 {
71 
72 #if defined _WINDOWS
73     MessageBox (NULL, message,
74 		(fatal ==
75 		 panda_true) ? "Fatal Panda Windows DLL error" :
76 		"Non-fatal Panda Windows DLL error", MB_OK);
77 
78 #else
79     fprintf (stderr, "%sError: %s\n", (fatal == panda_true) ? "Fatal " : "",
80 	     message);
81 #endif /*  */
82   if (fatal == panda_true)
83     exit (42);
84 }
85