Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TError.h
Go to the documentation of this file.
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 #include "Rtypes.h"
30 #include <stdarg.h>
31 
32 
33 class TVirtualMutex;
34 
35 const Int_t kUnset = -1;
36 const Int_t kPrint = 0;
37 const Int_t kInfo = 1000;
38 const Int_t kWarning = 2000;
39 const Int_t kError = 3000;
40 const Int_t kBreak = 4000;
41 const Int_t kSysError = 5000;
42 const Int_t kFatal = 6000;
43 
44 R__EXTERN TVirtualMutex *gErrorMutex;
45 
46 typedef void (*ErrorHandlerFunc_t)(int level, Bool_t abort, const char *location,
47  const char *msg);
48 
49 extern "C" void ErrorHandler(int level, const char *location, const char *fmt,
50  va_list va);
51 
52 extern void DefaultErrorHandler(int level, Bool_t abort, const char *location,
53  const char *msg);
54 
55 extern ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler);
56 extern ErrorHandlerFunc_t GetErrorHandler();
57 
58 extern void Info(const char *location, const char *msgfmt, ...)
59 #if defined(__GNUC__) && !defined(__CINT__)
60 __attribute__((format(printf, 2, 3)))
61 #endif
62 ;
63 extern void Warning(const char *location, const char *msgfmt, ...)
64 #if defined(__GNUC__) && !defined(__CINT__)
65 __attribute__((format(printf, 2, 3)))
66 #endif
67 ;
68 extern void Error(const char *location, const char *msgfmt, ...)
69 #if defined(__GNUC__) && !defined(__CINT__)
70 __attribute__((format(printf, 2, 3)))
71 #endif
72 ;
73 extern void Break(const char *location, const char *msgfmt, ...)
74 #if defined(__GNUC__) && !defined(__CINT__)
75 __attribute__((format(printf, 2, 3)))
76 #endif
77 ;
78 extern void SysError(const char *location, const char *msgfmt, ...)
79 #if defined(__GNUC__) && !defined(__CINT__)
80 __attribute__((format(printf, 2, 3)))
81 #endif
82 ;
83 extern void Fatal(const char *location, const char *msgfmt, ...)
84 #if defined(__GNUC__) && !defined(__CINT__)
85 __attribute__((format(printf, 2, 3)))
86 #endif
87 ;
88 
89 extern void AbstractMethod(const char *method);
90 extern void MayNotUse(const char *method);
91 extern void Obsolete(const char *function, const char *asOfVers, const char *removedFromVers);
92 
93 R__EXTERN const char *kAssertMsg;
94 R__EXTERN const char *kCheckMsg;
95 
96 #define R__ASSERT(e) \
97  do { \
98  if (!(e)) ::Fatal("", kAssertMsg, _QUOTE_(e), __LINE__, __FILE__); \
99  } while (false)
100 #define R__CHECK(e) \
101  do { \
102  if (!(e)) ::Warning("", kCheckMsg, _QUOTE_(e), __LINE__, __FILE__); \
103  } while (false)
104 
105 R__EXTERN Int_t gErrorIgnoreLevel;
106 R__EXTERN Int_t gErrorAbortLevel;
107 R__EXTERN Bool_t gPrintViaErrorHandler;
108 
109 #endif