Logo ROOT   6.12/07
Reference Guide
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 
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 
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 
108 
109 #endif
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
Set an errorhandler function. Returns the old handler.
Definition: TError.cxx:106
R__EXTERN Int_t gErrorIgnoreLevel
Definition: TError.h:105
R__EXTERN TVirtualMutex * gErrorMutex
Definition: TError.h:44
void Fatal(const char *location, const char *msgfmt,...)
void DefaultErrorHandler(int level, Bool_t abort, const char *location, const char *msg)
The default error handler function.
Definition: TError.cxx:125
R__EXTERN const char * kAssertMsg
Definition: TError.h:93
void AbstractMethod(const char *method)
This function can be used in abstract base classes in case one does not want to make the class a "rea...
Definition: TError.cxx:260
This class implements a mutex interface.
Definition: TVirtualMutex.h:34
R__EXTERN Int_t gErrorAbortLevel
Definition: TError.h:106
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void Break(const char *location, const char *msgfmt,...)
void Obsolete(const char *function, const char *asOfVers, const char *removedFromVers)
Use this function to declare a function obsolete.
Definition: TError.cxx:278
const Int_t kBreak
Definition: TError.h:40
void SysError(const char *location, const char *msgfmt,...)
const Int_t kSysError
Definition: TError.h:41
const Int_t kFatal
Definition: TError.h:42
void Info(const char *location, const char *msgfmt,...)
void Error(const char *location, const char *msgfmt,...)
void MayNotUse(const char *method)
This function can be used in classes that should override a certain function, but in the inherited cl...
Definition: TError.cxx:269
const Int_t kUnset
Definition: TError.h:35
R__EXTERN const char * kCheckMsg
Definition: TError.h:94
R__EXTERN Bool_t gPrintViaErrorHandler
Definition: TError.h:107
const Int_t kPrint
Definition: TError.h:36
const Int_t kInfo
Definition: TError.h:37
const Int_t kWarning
Definition: TError.h:38
void Warning(const char *location, const char *msgfmt,...)
void(* ErrorHandlerFunc_t)(int level, Bool_t abort, const char *location, const char *msg)
Definition: TError.h:46
#define R__EXTERN
Definition: DllImport.h:27
typedef void((*Func_t)())
ErrorHandlerFunc_t GetErrorHandler()
Returns the current error handler function.
Definition: TError.cxx:116
void ErrorHandler(int level, const char *location, const char *fmt, va_list va)
General error handler function. It calls the user set error handler.
Definition: TError.cxx:202
const Int_t kError
Definition: TError.h:39