1    	// @(#)root/base:$Id$
2    	// Author: Fons Rademakers   29/07/95
3    	
4    	/*************************************************************************
5    	 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
6    	 * All rights reserved.                                                  *
7    	 *                                                                       *
8    	 * For the licensing terms see $ROOTSYS/LICENSE.                         *
9    	 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
10   	 *************************************************************************/
11   	
12   	#ifndef ROOT_TError
13   	#define ROOT_TError
14   	
15   	
16   	//////////////////////////////////////////////////////////////////////////
17   	//                                                                      //
18   	// Error handling routines.                                             //
19   	//                                                                      //
20   	// This file defines a number of global error handling routines:        //
21   	// Warning(), Error(), SysError() and Fatal(). They all take a          //
22   	// location string (where the error happened) and a printf style format //
23   	// string plus vararg's. In the end these functions call an             //
24   	// errorhanlder function. By default DefaultErrorHandler() is used.     //
25   	//                                                                      //
26   	//////////////////////////////////////////////////////////////////////////
27   	
28   	
29   	#ifndef ROOT_Rtypes
30   	#include "Rtypes.h"
31   	#endif
32   	#include <stdarg.h>
33   	
34   	
35   	class TVirtualMutex;
36   	
37   	const Int_t kUnset    =  -1;
38   	const Int_t kPrint    =   0;
39   	const Int_t kInfo     =   1000;
40   	const Int_t kWarning  =   2000;
41   	const Int_t kError    =   3000;
42   	const Int_t kBreak    =   4000;
43   	const Int_t kSysError =   5000;
44   	const Int_t kFatal    =   6000;
45   	
46   	R__EXTERN TVirtualMutex *gErrorMutex;
47   	
48   	typedef void (*ErrorHandlerFunc_t)(int level, Bool_t abort, const char *location,
49   	              const char *msg);
50   	
51   	extern "C" void ErrorHandler(int level, const char *location, const char *fmt,
52   	                             va_list va);
53   	
54   	extern void DefaultErrorHandler(int level, Bool_t abort, const char *location,
55   	                                const char *msg);
56   	
57   	extern ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler);
58   	extern ErrorHandlerFunc_t GetErrorHandler();
59   	
60   	extern void Info(const char *location, const char *msgfmt, ...)
61   	#if defined(__GNUC__) && !defined(__CINT__)
62   	__attribute__((format(printf, 2, 3)))
63   	#endif
64   	;
65   	extern void Warning(const char *location, const char *msgfmt, ...)
66   	#if defined(__GNUC__) && !defined(__CINT__)
67   	__attribute__((format(printf, 2, 3)))
68   	#endif
69   	;
70   	extern void Error(const char *location, const char *msgfmt, ...)
71   	#if defined(__GNUC__) && !defined(__CINT__)
72   	__attribute__((format(printf, 2, 3)))
73   	#endif
74   	;
75   	extern void Break(const char *location, const char *msgfmt, ...)
76   	#if defined(__GNUC__) && !defined(__CINT__)
77   	__attribute__((format(printf, 2, 3)))
78   	#endif
79   	;
80   	extern void SysError(const char *location, const char *msgfmt, ...)
81   	#if defined(__GNUC__) && !defined(__CINT__)
82   	__attribute__((format(printf, 2, 3)))
83   	#endif
84   	;
85   	extern void Fatal(const char *location, const char *msgfmt, ...)
86   	#if defined(__GNUC__) && !defined(__CINT__)
87   	__attribute__((format(printf, 2, 3)))
88   	#endif
89   	;
90   	
91   	extern void AbstractMethod(const char *method);
92   	extern void MayNotUse(const char *method);
93   	extern void Obsolete(const char *function, const char *asOfVers, const char *removedFromVers);
94   	
95   	R__EXTERN const char *kAssertMsg;
96   	R__EXTERN const char *kCheckMsg;
97   	
98   	#define R__ASSERT(e) \
99   	   do { \
100  	      if (!(e)) ::Fatal("", kAssertMsg, _QUOTE_(e), __LINE__, __FILE__); \
101  	   } while (0)
102  	#define R__CHECK(e) \
103  	   do { \
104  	      if (!(e)) ::Warning("", kCheckMsg, _QUOTE_(e), __LINE__, __FILE__); \
105  	   } while (0)
106  	
107  	R__EXTERN Int_t  gErrorIgnoreLevel;
108  	R__EXTERN Int_t  gErrorAbortLevel;
109  	R__EXTERN Bool_t gPrintViaErrorHandler;
110  	
111  	#endif
112