ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 #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 
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 
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 
110 
111 #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:107
R__EXTERN TVirtualMutex * gErrorMutex
Definition: TError.h:46
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:95
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:108
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void Break(const char *location, const char *msgfmt,...)
static std::string format(double x, double y, int digits, int width)
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:42
void SysError(const char *location, const char *msgfmt,...)
const Int_t kSysError
Definition: TError.h:43
const Int_t kFatal
Definition: TError.h:44
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:37
R__EXTERN const char * kCheckMsg
Definition: TError.h:96
R__EXTERN Bool_t gPrintViaErrorHandler
Definition: TError.h:109
const Int_t kPrint
Definition: TError.h:38
const Int_t kInfo
Definition: TError.h:39
const Int_t kWarning
Definition: TError.h:40
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:48
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
#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:41