Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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. Initially, a minimal, non thread-safe handler //
25// is installed that is supposed to be replaced by the //
26// DefaultErrorHandler(), which needs to be implemented and installed //
27// by the user of TError. Normally, the default error handler is set //
28// during gROOT initialization. //
29// //
30//////////////////////////////////////////////////////////////////////////
31
32
33#include <DllImport.h> // for R__EXTERN
34#include "RtypesCore.h"
35
36#include <cstdarg>
37#include <functional>
38
39
40class TVirtualMutex;
41
50
51// TROOT sets the error ignore level handler, the system error message handler, and the error abort handler on
52// construction such that the "Root.ErrorIgnoreLevel" environment variable is used for the ignore level
53// and gSystem is used to generate a stack trace on abort.
54namespace ROOT {
55namespace Internal {
56
57/// Retrieves the error string associated with the last system error.
58using ErrorSystemMsgHandlerFunc_t = std::function<const char *()>;
59
61/// Returns the previous system error message handler
63
64void MinimalErrorHandler(int level, Bool_t abort, const char *location, const char *msg);
65
66} // namespace Internal
67} // namespace ROOT
68
69typedef void (*ErrorHandlerFunc_t)(int level, Bool_t abort, const char *location,
70 const char *msg);
71
72extern "C" void ErrorHandler(int level, const char *location, const char *fmt, std::va_list va);
73
74extern void DefaultErrorHandler(int level, Bool_t abort, const char *location, const char *msg);
75
78
79extern void Info(const char *location, const char *msgfmt, ...)
80#if defined(__GNUC__) && !defined(__CINT__)
81__attribute__((format(printf, 2, 3)))
82#endif
83;
84extern void Warning(const char *location, const char *msgfmt, ...)
85#if defined(__GNUC__) && !defined(__CINT__)
86__attribute__((format(printf, 2, 3)))
87#endif
88;
89extern void Error(const char *location, const char *msgfmt, ...)
90#if defined(__GNUC__) && !defined(__CINT__)
91__attribute__((format(printf, 2, 3)))
92#endif
93;
94extern void Break(const char *location, const char *msgfmt, ...)
95#if defined(__GNUC__) && !defined(__CINT__)
96__attribute__((format(printf, 2, 3)))
97#endif
98;
99extern void SysError(const char *location, const char *msgfmt, ...)
100#if defined(__GNUC__) && !defined(__CINT__)
101__attribute__((format(printf, 2, 3)))
102#endif
103;
104extern void Fatal(const char *location, const char *msgfmt, ...)
105#if defined(__GNUC__) && !defined(__CINT__)
106__attribute__((format(printf, 2, 3)))
107#endif
108;
109
110extern void AbstractMethod(const char *method);
111extern void MayNotUse(const char *method);
112extern void Obsolete(const char *function, const char *asOfVers, const char *removedFromVers);
113
114R__EXTERN const char *kAssertMsg;
115R__EXTERN const char *kCheckMsg;
116
117#define R__ASSERT(e) \
118 do { \
119 if (!(e)) ::Fatal("", kAssertMsg, _QUOTE_(e), __LINE__, __FILE__); \
120 } while (false)
121#define R__CHECK(e) \
122 do { \
123 if (!(e)) ::Warning("", kCheckMsg, _QUOTE_(e), __LINE__, __FILE__); \
124 } while (false)
125
129
130#endif
#define R__EXTERN
Definition DllImport.h:27
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
void DefaultErrorHandler(int level, Bool_t abort, const char *location, const char *msg)
The default error handler function.
Int_t gErrorAbortLevel
Definition TError.cxx:44
const char * kAssertMsg
Definition TError.cxx:47
const Int_t kPrint
Definition TError.cxx:35
const Int_t kError
Definition TError.cxx:38
const Int_t kSysError
Definition TError.cxx:40
void ErrorHandler(int level, const char *location, const char *fmt, std::va_list va)
General error handler function. It calls the user set error handler.
Definition TError.cxx:121
ErrorHandlerFunc_t GetErrorHandler()
Returns the current error handler function.
Definition TError.cxx:112
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:230
const Int_t kUnset
Definition TError.cxx:34
const Int_t kFatal
Definition TError.cxx:41
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:197
const Int_t kBreak
Definition TError.cxx:39
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:171
const Int_t kWarning
Definition TError.cxx:37
void SysError(const char *location, const char *msgfmt,...)
Use this function in case a system (OS or GUI) related error occurred.
Definition TError.cxx:208
void(* ErrorHandlerFunc_t)(int level, Bool_t abort, const char *location, const char *msg)
Definition TError.h:69
void Break(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:219
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:180
Int_t gErrorIgnoreLevel
Definition TError.cxx:43
const char * kCheckMsg
Definition TError.cxx:48
void Obsolete(const char *function, const char *asOfVers, const char *removedFromVers)
Use this function to declare a function obsolete.
Definition TError.cxx:189
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:241
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
Set an errorhandler function. Returns the old handler.
Definition TError.cxx:102
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
Definition TError.cxx:256
const Int_t kInfo
Definition TError.cxx:36
Bool_t gPrintViaErrorHandler
Definition TError.cxx:45
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t format
This class implements a mutex interface.
std::function< const char *()> ErrorSystemMsgHandlerFunc_t
Retrieves the error string associated with the last system error.
Definition TError.h:58
void MinimalErrorHandler(int level, Bool_t abort, const char *location, const char *msg)
A very simple error handler that is usually replaced by the TROOT default error handler.
Definition TError.cxx:79
ErrorSystemMsgHandlerFunc_t SetErrorSystemMsgHandler(ErrorSystemMsgHandlerFunc_t h)
Returns the previous system error message handler.
Definition TError.cxx:68
ErrorSystemMsgHandlerFunc_t GetErrorSystemMsgHandler()
Definition TError.cxx:63
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.