w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ErrorHandler Class Reference

Error reporting class. More...

#include <error.hh>

Inheritance diagram for ErrorHandler:
[legend]
Collaboration diagram for ErrorHandler:
[legend]

Classes

struct  Conversion
 

Public Types

enum  Level {
  el_abort = -999 , el_fatal = -1 , el_emergency = 0 , el_alert = 1 ,
  el_critical = 2 , el_error = 3 , el_warning = 4 , el_notice = 5 ,
  el_info = 6 , el_debug = 7
}
 Error level constants. More...
 
enum  ConversionFlags {
  cf_zero_pad = 1 , cf_plus_positive = 2 , cf_space_positive = 4 , cf_left_just = 8 ,
  cf_alternate_form = 16 , cf_singlequote = 32 , cf_uppercase = 64 , cf_signed = 128 ,
  cf_negative = 256 , cf_utf8 = 1024
}
 
typedef String(* ConversionFunction) (int flags, va_list)
 

Public Member Functions

 ErrorHandler ()
 Construct an ErrorHandler. More...
 
virtual ~ErrorHandler ()
 
void debug (const char *fmt,...)
 levels <4> and below More...
 
void message (const char *fmt,...)
 Print an informational message (level el_info). More...
 
int warning (const char *fmt,...)
 Print a warning message (level el_warning). More...
 
int error (const char *fmt,...)
 Print an error message (level el_error). More...
 
void fatal (const char *fmt,...)
 Print a fatal error message (level el_fatal). More...
 
void ldebug (const String &landmark, const char *fmt,...)
 Print a debug message with a landmark annotation. More...
 
void lmessage (const String &landmark, const char *fmt,...)
 Print an informational message with a landmark annotation. More...
 
int lwarning (const String &landmark, const char *fmt,...)
 Print a warning message with a landmark annotation. More...
 
int lerror (const String &landmark, const char *fmt,...)
 Print an error message with a landmark annotation. More...
 
void lfatal (const String &landmark, const char *fmt,...)
 Print a fatal error message with a landmark annotation. More...
 
int xmessage (const String &str)
 Print an annotated error message. More...
 
int xmessage (const String &anno, const String &str)
 Print an error message, adding annotations. More...
 
int xmessage (const String &anno, const char *fmt, va_list val)
 Format and print an error message, adding annotations. More...
 
int xmessage (const String &landmark, const String &anno, const String &str)
 Print an error message, adding landmark and other annotations. More...
 
int xmessage (const String &landmark, const String &anno, const char *fmt, va_list val)
 Format and print an error message, adding landmark and other annotations. More...
 
int nerrors () const
 Return the number of errors reported via this handler. More...
 
virtual String vformat (const char *fmt, va_list val)
 Format an error string. More...
 
String format (const char *fmt,...)
 Format an error string. More...
 
virtual String decorate (const String &str)
 Decorate an error message. More...
 
virtual voidemit (const String &str, void *user_data, bool more)
 Output an error message line. More...
 
virtual void account (int level)
 Account for an error message at level level. More...
 
virtual void clear ()
 Clear accumulated error state. More...
 

Static Public Member Functions

static ErrorHandlerstatic_initialize (ErrorHandler *errh)
 Initialize the ErrorHandler implementation. More...
 
static void static_cleanup ()
 Tear down the ErrorHandler implementation. More...
 
static ErrorHandlerdefault_handler ()
 Return the default ErrorHandler. More...
 
static void set_default_handler (ErrorHandler *errh)
 Set the default ErrorHandler to errh. More...
 
static ErrorHandlersilent_handler ()
 Return the global silent ErrorHandler. More...
 
static String xformat (int default_flags, const char *fmt,...)
 Format an error string. More...
 
static String vxformat (int default_flags, const char *fmt, va_list val)
 
static String xformat (const char *fmt,...)
 
static String vxformat (const char *fmt, va_list val)
 
static String make_anno (const char *name, const String &value)
 Create an error annotation. More...
 
static String combine_anno (const String &str, const String &anno)
 Apply annotations from anno to every line in str. More...
 
static const char * parse_anno (const String &str, const char *begin, const char *end,...)
 Parse error annotations from a string. More...
 
static const char * skip_anno (const char *begin, const char *end)
 Skip a string's error annotations. More...
 
static String make_landmark_anno (const String &x)
 Return a landmark annotation equal to x. More...
 
static String clean_landmark (const String &landmark, bool colon=false)
 Clean the landmark. More...
 
static Conversionadd_conversion (const String &name, ConversionFunction func)
 
static int remove_conversion (Conversion *conversion)
 

Static Public Attributes

static const char e_abort [] = "<-999>"
 Error level indicators. More...
 
static const char e_fatal [] = "<-1>"
 
static const char e_emergency [] = "<0>"
 
static const char e_alert [] = "<1>"
 
static const char e_critical [] = "<2>"
 
static const char e_error [] = "<3>"
 
static const char e_warning [] = "<4>"
 
static const char e_warning_annotated [] = "<4>warning: "
 
static const char e_notice [] = "<5>"
 
static const char e_info [] = "<6>"
 
static const char e_debug [] = "<7>"
 
static const int ok_result = 0
 
static const int error_result = -EINVAL
 <5> and above More...
 

Static Private Member Functions

static const char * skip_anno (const String &str, const char *begin, const char *end, String *name_result, String *value_result, bool raw)
 

Private Attributes

int _nerrors
 

Static Private Attributes

static ErrorHandlerthe_default_handler = 0
 
static ErrorHandlerthe_silent_handler = 0
 

Detailed Description

Error reporting class.

Report errors through ErrorHandler objects, which represent error collectors and printers. ErrorHandlers are passed to configure() and initialize() methods explicitly, as well as to write handlers; the click_chatter() function calls ErrorHandler implicitly.

Cooked error messages

Most ErrorHandler interactions consist of a simple call like this:

errh->error("not enough arguments (%d needed)", 5);
// prints something like "not enough arguments (5 needed)\n"
int error(const char *fmt,...)
Print an error message (level el_error).
Definition: error.cc:818
static ErrorHandler * errh
Definition: main.cc:71

This function constructs an error message string from the format arguments, annotates the string with a default error level (here, el_error), and prints it. Alternate versions take a landmark specifying where the error took place:

errh->lwarning("file.click:2", "syntax error at '%s'", word.c_str());
// prints something like "file.click:2: syntax error at 'foo'\n"
int lwarning(const String &landmark, const char *fmt,...)
Print a warning message with a landmark annotation.
Definition: error.cc:858
unsigned short word
Definition: picttoppm.c:64

Raw error messages

For finer control over error levels and annotations, construct an error message string directly. An error message is a string consisting of one or more lines. Each line begins with a set of optional textual annotations. The following error message has a level annotation determining how serious the error is (this one is critical, since el_critical == 2), and a landmark annotation, which specifies where the error took place (here, "x.click:1"):

"<2>{l:x.click:1}syntax error"

The default ErrorHandlers understand the level and landmark annotations. Users can add other arbitrary annotations, which can be useful to pass error metadata. A pair of braces ends the annotation area. This example has one user annotation eoc, and a message area that would be mistaken for an annotation were it not for the {}:

"<2>{l:x.click:1}{eoc:520}{}{not:an annotation}"

Stacking handlers

Some ErrorHandlers stack on top of others, adding useful functionality like automatic context description and prefixing. For example, ContextErrorHandler can be used to print messages like "In function 'xxx':".

FileErrorHandler errh1(stderr);
ContextErrorHandler errh2(&errh1, "While counting to 2:");
errh2.error("An error occurred.");
errh2.error("Another error occurred.");
// prints "While counting to 2:\n"
// " An error occurred.\n"
// " Another error occurred.\n"
A stackable ErrorHandler that prints context lines.
Definition: error.hh:728
An ErrorHandler that prints error messages to a given file.
Definition: error.hh:640

Definition at line 86 of file error.hh.

Member Typedef Documentation

◆ ConversionFunction

typedef String(* ErrorHandler::ConversionFunction) (int flags, va_list)

Definition at line 556 of file error.hh.

Member Enumeration Documentation

◆ ConversionFlags

Enumerator
cf_zero_pad 

Set for conversions using the '0' flag.

cf_plus_positive 

Set for conversions using the '+' flag.

cf_space_positive 

Set for conversions using the ' ' flag.

cf_left_just 

Set for conversions using the '-' flag.

cf_alternate_form 

Set for conversions using the '#' flag.

cf_singlequote 

Set for conversions using the '\'' flag.

cf_uppercase 

Set for 'X' conversions (not 'x').

cf_signed 

Set for conversions of signed numbers.

cf_negative 

Set for conversions of negative numbers.

cf_utf8 

Set to use UTF-8 characters on output.

Definition at line 557 of file error.hh.

◆ Level

Error level constants.

Lower values represent more serious errors. Levels 0-7 correspond to Linux's error levels. Negative levels request immediate exit; at user level, the exit status is the absolute value of the error level.

Enumerator
el_abort 

Error level that triggers abort().

el_fatal 

Fatal exit error level.

el_emergency 

Exit status equals -(level).

Emergency error level: system is unusable.

el_alert 

Alert error level: action must be taken.

el_critical 

Error level for critical conditions.

el_error 

Error level for normal error conditions.

el_warning 

Error level for warning conditions.

el_notice 

Error level for normal, but significant

el_info 

conditions.

Error level for informational messages.

el_debug 

Error level for debug messages.

Definition at line 94 of file error.hh.

Constructor & Destructor Documentation

◆ ErrorHandler()

ErrorHandler::ErrorHandler ( )
inline

Construct an ErrorHandler.

Definition at line 123 of file error.hh.

◆ ~ErrorHandler()

virtual ErrorHandler::~ErrorHandler ( )
inlinevirtual

Definition at line 127 of file error.hh.

Member Function Documentation

◆ account()

void ErrorHandler::account ( int  level)
virtual

Account for an error message at level level.

Parameters
levelminimum error level in the message
Warning
ErrorHandler users don't need to call this function directly; it is called implicitly by the error()/xmessage() functions.

After calling emit() for the lines of an error message, ErrorHandler calls account(), passing the minimum (worst) error level of any message line (or 1000 if no line had a level). The default implementation updates the nerrors() counter, and exits the program if level is small enough.

Reimplemented in ErrorVeneer, and BailErrorHandler.

Definition at line 932 of file error.cc.

References _nerrors, abort(), el_abort, el_error, el_fatal, exit(), and level.

Referenced by ErrorVeneer::account(), and xmessage().

◆ add_conversion()

ErrorHandler::Conversion * ErrorHandler::add_conversion ( const String name,
ConversionFunction  func 
)
static

Definition at line 993 of file error.cc.

References c, error_items, and name.

◆ clean_landmark()

String ErrorHandler::clean_landmark ( const String landmark,
bool  colon = false 
)
static

Clean the landmark.

Parameters
landmarklandmark text
colonif true, append ": " to a nonempty landmark

Removes trailing space and an optional trailing colon from landmark and returns the result. If colon is true, and the cleaned landmark isn't the empty string, then appends ": " to the result.

Definition at line 301 of file error.cc.

Referenced by FileErrorHandler::emit().

◆ clear()

virtual void ErrorHandler::clear ( )
inlinevirtual

Clear accumulated error state.

The default implementation sets the nerrors() counter to zero.

Definition at line 438 of file error.hh.

References _nerrors.

◆ combine_anno()

String ErrorHandler::combine_anno ( const String str,
const String anno 
)
static

Apply annotations from anno to every line in str.

Parameters
strstring
annoannotation string

The annotations from anno are applied to every line in str. New annotations do not override existing annotations with the same names. If the anno string ends with non-annotation characters, this substring is prefixed to every line in str.

For example:

combine_anno("Line 1\n{l:old}{x:x}Line 2\n", "<0>{l:new} ")
// returns "<0>{l:new} Line 1\n<0>{l:old}{x:x} Line 2\n"
static String combine_anno(const String &str, const String &anno)
Apply annotations from anno to every line in str.
Definition: error.cc:238

Definition at line 238 of file error.cc.

Referenced by ContextErrorHandler::ContextErrorHandler(), ContextErrorHandler::decorate(), PrefixErrorHandler::decorate(), LandmarkErrorHandler::decorate(), and xmessage().

◆ debug()

void ErrorHandler::debug ( const char *  fmt,
  ... 
)

levels <4> and below

Print a debug message (level el_debug).

fmt and any following arguments are parsed as by format(), and the resulting string is passed to xmessage().

Definition at line 790 of file error.cc.

References e_debug, fmt, String::make_stable(), va_end, va_start, val, and xmessage().

◆ decorate()

String ErrorHandler::decorate ( const String str)
virtual

Decorate an error message.

Parameters
strerror message, possibly with annotations
Returns
decorated error message
Warning
ErrorHandler users don't need to call this function directly; it is called implicitly by the error()/xmessage() functions.

This virtual function is called to decorate an error message before it is emitted. The input str is an error message string, possibly annotated. The default implementation returns str unchanged. Other ErrorHandlers might add context lines (ContextErrorHandler), prefixes (PrefixErrorHandler), or a default landmark (LandmarkErrorHandler).

Reimplemented in ErrorVeneer, ContextErrorHandler, PrefixErrorHandler, LandmarkErrorHandler, and CharstringCheckerErrorHandler< T >.

Definition at line 920 of file error.cc.

References str.

Referenced by ErrorVeneer::decorate(), and xmessage().

◆ default_handler()

static ErrorHandler* ErrorHandler::default_handler ( )
inlinestatic

◆ emit()

void * ErrorHandler::emit ( const String str,
void user_data,
bool  more 
)
virtual

Output an error message line.

Parameters
strerror message line, possibly with annotations
user_datacallback data, 0 for first line in a message
moretrue iff this is the last line in the current message
Returns
user_data to be passed to emit() for the next line
Warning
ErrorHandler users don't need to call this function directly; it is called implicitly by the error()/xmessage() functions.

After calling decorate(), ErrorHandler splits the message into individual lines and calls emit() once per line. ErrorHandler subclasses should output the error lines as appropriate; for example, FileErrorHandler outputs the error message to a file.

str does not contain a newline, but may contain annotations, including a landmark annotation. Most ErrorHandlers use parse_anno() to extract the landmark annotation, clean it with clean_landmark(), and print it ahead of the error message proper.

ErrorHandler can handle multi-line error messages. However, the emit() function takes a line at a time; this is more useful in practice for most error message printers. The user_data and more arguments can help an ErrorHandler combine the lines of a multi-line error message. user_data is null for the first line; for second and subsequent lines, ErrorHandler passes the result of the last line's emit() call. more is true iff this is the last line in the current message.

The default emit() implementation does nothing.

Reimplemented in ErrorVeneer, and FileErrorHandler.

Definition at line 926 of file error.cc.

Referenced by ErrorVeneer::emit(), and xmessage().

◆ error()

int ErrorHandler::error ( const char *  fmt,
  ... 
)

Print an error message (level el_error).

Returns
error_result

Definition at line 818 of file error.cc.

References e_error, fmt, String::make_stable(), r, va_end, va_start, val, and xmessage().

Referenced by GlyphFilter::add_pattern(), Efont::Cff::Dict::assign(), Efont::Cff::Charset::assign(), CharstringChecker::callothersubr(), Efont::Cff::Dict::check(), CharstringSubrChecker::check(), Efont::OpenType::Coverage::check(), Efont::OpenType::ClassDef::check(), check_blue_array(), check_blue_overlap(), check_blues(), Efont::OpenType::Font::check_checksums(), Efont::OpenType::ScriptList::check_header(), Efont::OpenType::FeatureList::check_header(), Efont::OpenType::ScriptList::check_script(), CharstringChecker::check_stem3(), check_stem_snap(), check_stems(), Efont::OpenType::Cmap::check_table(), Efont::Cff::ChildFont::ChildFont(), Efont::Cff::CIDFont::CIDFont(), Efont::Type1Font::create_mmspace(), do_dump_table(), do_file(), do_query_glyphs_cff(), T1Secondary::dotlessj_font(), CharstringChecker::error(), CharstringSubrChecker::error(), Efont::OpenType::ScriptList::features(), find_lookups(), Efont::Cff::font(), FontInfo::FontInfo(), get_integer(), get_num_array(), Efont::Cff::IndexIterator::IndexIterator(), installed_truetype(), installed_type1(), installed_type42(), Efont::OpenType::FeatureList::lookups(), main(), Efont::AmfmMetrics::master(), Efont::MultipleMasterSpace::normalize_vector(), output_metrics(), output_pl(), Efont::OpenType::FeatureList::params(), Efont::Cff::FDSelect::parse(), Efont::Cff::Charset::parse(), parse_base_encodings(), Efont::Cff::Font::parse_encoding(), Efont::Cff::parse_header(), Efont::OpenType::Font::parse_header(), Efont::OpenType::Cmap::parse_header(), Efont::OpenType::Name::parse_header(), Efont::OpenType::Os2::parse_header(), Efont::OpenType::Post::parse_header(), Efont::OpenType::Head::parse_header(), DvipsEncoding::parse_ligkern_words(), DvipsEncoding::parse_position_words(), DvipsEncoding::parse_word_group(), Efont::AmfmReader::read(), Type1MMRemover::run(), Efont::AmfmMetrics::sanity(), MyFont::set_design_vector(), Efont::OpenType::FeatureList::size_params(), temporary_file(), CharstringChecker::type1_command(), update_autofont_map(), update_odir(), and write_encoding_file().

◆ fatal()

void ErrorHandler::fatal ( const char *  fmt,
  ... 
)

Print a fatal error message (level el_fatal).

Returns
error_result

Calling fatal() will cause the process to abort.

Definition at line 828 of file error.cc.

References abort(), e_fatal, fmt, String::make_stable(), va_end, va_start, val, void, and xmessage().

Referenced by do_file(), main(), output_pl(), output_tfm(), read_file(), set_amfm(), Sectioner::undot(), and update_autofont_map().

◆ format()

String ErrorHandler::format ( const char *  fmt,
  ... 
)

Format an error string.

Parameters
fmtformat string
Warning
ErrorHandler users don't usually need to call this function directly.

This is a convenience function that calls vformat(const char *fmt, va_list val) for a va_list taken from the ellipsis arguments.

Definition at line 777 of file error.cc.

References fmt, s, va_end, va_start, val, and vformat().

Referenced by MakeType1CharstringInterp::landmark(), and report_underused_features().

◆ ldebug()

void ErrorHandler::ldebug ( const String landmark,
const char *  fmt,
  ... 
)

Print a debug message with a landmark annotation.

Definition at line 838 of file error.cc.

References e_debug, fmt, cutout::l, landmark(), make_landmark_anno(), String::make_stable(), va_end, va_start, val, and xmessage().

◆ lerror()

int ErrorHandler::lerror ( const String landmark,
const char *  fmt,
  ... 
)

Print an error message with a landmark annotation.

Definition at line 869 of file error.cc.

References e_error, fmt, cutout::l, landmark(), make_landmark_anno(), String::make_stable(), r, va_end, va_start, val, and xmessage().

Referenced by do_file(), DvipsEncoding::parse(), parse_encoding(), Efont::AmfmReader::read(), and update_autofont_map().

◆ lfatal()

void ErrorHandler::lfatal ( const String landmark,
const char *  fmt,
  ... 
)

Print a fatal error message with a landmark annotation.

Definition at line 880 of file error.cc.

References abort(), e_fatal, fmt, cutout::l, landmark(), make_landmark_anno(), String::make_stable(), va_end, va_start, val, void, and xmessage().

◆ lmessage()

void ErrorHandler::lmessage ( const String landmark,
const char *  fmt,
  ... 
)

Print an informational message with a landmark annotation.

Definition at line 848 of file error.cc.

References e_info, fmt, cutout::l, landmark(), make_landmark_anno(), String::make_stable(), va_end, va_start, val, and xmessage().

Referenced by Metrics::shrink_encoding().

◆ lwarning()

int ErrorHandler::lwarning ( const String landmark,
const char *  fmt,
  ... 
)

Print a warning message with a landmark annotation.

Definition at line 858 of file error.cc.

References e_warning_annotated, fmt, cutout::l, landmark(), make_landmark_anno(), String::make_stable(), r, va_end, va_start, val, and xmessage().

Referenced by DvipsEncoding::parse(), parse_encoding(), MakeType1CharstringInterp::run(), and Metrics::shrink_encoding().

◆ make_anno()

String ErrorHandler::make_anno ( const char *  name,
const String value 
)
static

Create an error annotation.

Parameters
nameannotation name
valueannotation value
Returns
annotation string

Returns an error annotation that associates annotation name with value.

If name equals "<>", then returns a level annotation of the form "<@a value>". value must be valid number; if it isn't, the function returns the empty string.

Otherwise, name must be a nonempty series of letters and digits. make_anno() returns a string of the form "{@a name:@a value}", where special characters in value are quoted with backslashes.

Definition at line 98 of file error.cc.

References n, name, parse_level(), and StringAccum::reserve().

Referenced by make_landmark_anno().

◆ make_landmark_anno()

static String ErrorHandler::make_landmark_anno ( const String x)
inlinestatic

Return a landmark annotation equal to x.

Parameters
xlandmark

If x is empty, returns the empty string. Otherwise, if x looks like a formatted annotation (it starts with an open brace), returns x unchanged. Otherwise, returns make_anno("l", x).

Definition at line 535 of file error.hh.

References make_anno(), and cordic::x.

Referenced by ldebug(), lerror(), lfatal(), lmessage(), lwarning(), read_file(), ContextErrorHandler::set_context_landmark(), LandmarkErrorHandler::set_landmark(), and xmessage().

◆ message()

◆ nerrors()

int ErrorHandler::nerrors ( ) const
inline

Return the number of errors reported via this handler.

An error is any message that contains at least one line with error level 3 (el_error) or below.

Note
The error count will also contain errors reported via stacked handlers. For instance:
PrefixErrorHandler errh2(&errh1, "");
assert(errh1.nerrors() == 0);
errh2.error("blah");
assert(errh1.nerrors() == 1);
int nerrors() const
Return the number of errors reported via this handler.
Definition: error.hh:282
A stackable ErrorHandler that adds a prefix to error messages.
Definition: error.hh:799
An ErrorHandler that does not report messages.
Definition: error.hh:592
assert(pcxLoadImage24((char *)((void *) 0), fp, pinfo, hdr))
See also
account, clear

Definition at line 282 of file error.hh.

References _nerrors.

Referenced by Efont::Cff::Dict::check(), CharstringChecker::check(), CharstringSubrChecker::check(), do_dump_table(), do_file(), do_info(), do_query_family_name(), do_query_font_version(), do_query_glyphs(), do_query_optical_size(), do_query_optical_size_size(), do_query_postscript_name(), do_tables(), main(), output_metrics(), DvipsEncoding::parse(), and parse_base_encodings().

◆ parse_anno()

const char * ErrorHandler::parse_anno ( const String str,
const char *  begin,
const char *  end,
  ... 
)
static

Parse error annotations from a string.

Parameters
strthe string
beginpointer within str to start of annotation area
endpointer to end of error region, usually str.end()
Returns
pointer to first character after annotation area
Precondition
str.begin() <= {begin, end} <= str.end()
Postcondition
begin <= returned value <= end

Use this function to skip an error line's annotation area, possibly extracting named annotations.

The variable arguments portion consists of a series of pairs of C strings and value pointers, terminated by a null character pointer. Each C string is an annotation name. The corresponding annotation value, if found, is stored as a String object in the value pointer. You can also store the int value of an annotation by prefixing an annotation name with the '#' character.

For example:

String line = "{l:file:30}<4.5>error message\n";
String landmark_str, level_str;
const char *s = ErrorHandler::parse_anno(line, line.begin(), line.end(),
"l", &landmark_str, "<>", &level_str, (const char *) 0);
// Results: s points to "error message\n",
// landmark_str == "file:30", level_str == "4.5"
int level;
"#<>", &level, (const char *) 0);
// Results: s points to "error message\n", level_str == 4
int level
Definition: afm2pl.c:1694
static const char * parse_anno(const String &str, const char *begin, const char *end,...)
Parse error annotations from a string.
Definition: error.cc:200
#define s
Definition: afcover.h:80
A string of characters.
Definition: t1part.c:49
Definition: bdf.c:133

Definition at line 200 of file error.cc.

Referenced by ContextErrorHandler::decorate(), FileErrorHandler::emit(), and xmessage().

◆ remove_conversion()

int ErrorHandler::remove_conversion ( ErrorHandler::Conversion conv)
static

Definition at line 1006 of file error.cc.

References c, conv, and error_items.

◆ set_default_handler()

void ErrorHandler::set_default_handler ( ErrorHandler errh)
static

Set the default ErrorHandler to errh.

Note
errh becomes property of the ErrorHandler implementation, and will be freed by static_cleanup(). However, any prior default handler is not destroyed. Callers should delete the prior handler when necessary.

Definition at line 1042 of file error.cc.

References errh, and the_default_handler.

◆ silent_handler()

◆ skip_anno() [1/2]

static const char* ErrorHandler::skip_anno ( const char *  begin,
const char *  end 
)
inlinestatic

Skip a string's error annotations.

Parameters
beginpointer to start of string
endpointer one past end of string
Returns
pointer to first character after annotation area
Postcondition
begin <= returned value <= end

Use this function to skip an error line's annotation area. The error line is defined as a pair of iterators.

Definition at line 519 of file error.hh.

References begin, end, name, and cordic::x.

◆ skip_anno() [2/2]

const char * ErrorHandler::skip_anno ( const String str,
const char *  begin,
const char *  end,
String name_result,
String value_result,
bool  raw 
)
staticprivate

Definition at line 130 of file error.cc.

◆ static_cleanup()

void ErrorHandler::static_cleanup ( )
static

Tear down the ErrorHandler implementation.

Deletes the internal ErrorHandlers and uninstalls default conversions.

Definition at line 1029 of file error.cc.

References error_items, ErrorHandler::Conversion::next, next, the_default_handler, and the_silent_handler.

◆ static_initialize()

ErrorHandler * ErrorHandler::static_initialize ( ErrorHandler errh)
static

Initialize the ErrorHandler implementation.

Parameters
errhdefault error handler
Returns
errh

Call this function to initialize the ErrorHandler implementation. The function installs the default conversions, creates the silent_handler(), and installs errh as the default error handler (see default_handler()).

Note
The errh object becomes the property of the ErrorHandler implementation and must not be deleted. (ErrorHandler::static_cleanup() will delete it.) Only the first call to static_initialize() has any effect.

Definition at line 1019 of file error.cc.

References default_handler(), the_default_handler, and the_silent_handler.

Referenced by main().

◆ vformat()

String ErrorHandler::vformat ( const char *  fmt,
va_list  val 
)
virtual

Format an error string.

Parameters
fmtformat string
valargument list
Warning
ErrorHandler users don't need to call this function directly; it is called implicitly by the error()/xmessage() functions.

This virtual function is called to format an error message. The default implementation returns the result of vxformat(fmt, val).

Reimplemented in ErrorVeneer, and FileErrorHandler.

Definition at line 914 of file error.cc.

References fmt, and vxformat().

Referenced by format(), ErrorVeneer::vformat(), and xmessage().

◆ vxformat() [1/2]

static String ErrorHandler::vxformat ( const char *  fmt,
va_list  val 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 351 of file error.hh.

References fmt, and vxformat().

◆ vxformat() [2/2]

String ErrorHandler::vxformat ( int  default_flags,
const char *  fmt,
va_list  val 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 385 of file error.cc.

References assert(), base, braces, c, StringAccum::data(), dest, do_number(), do_number_flags(), error, error_items, f, find(), flags, format, int(), int64_t, isdigit, isspace, item, len, StringAccum::length(), String::make_stable(), memcpy, memset(), num, number, NUMBUF_SIZE, pct, number::impl::stem_to_object::precision(), s, s1, s2, gen-indic-table::short, slen, sprintf, strchr, strcpy(), strlen(), strnlen(), String::substring(), uintmax_t, v, va_arg, and VA_LIST_REF.

Referenced by vformat(), FileErrorHandler::vformat(), vxformat(), and xformat().

◆ warning()

◆ xformat() [1/2]

String ErrorHandler::xformat ( const char *  fmt,
  ... 
)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 767 of file error.cc.

References fmt, s, va_end, va_start, val, and vxformat().

◆ xformat() [2/2]

String ErrorHandler::xformat ( int  default_flags,
const char *  fmt,
  ... 
)
static

Format an error string.

Parameters
default_flagsdefault ConversionFlags
fmtprintf-like format string
Returns
formatted error string

Formats an error string using printf-like % conversions. Conversions include:

%d, %i

Format an int as a decimal string. Understands flags in #0- +, field widths (including *), and precisions.

%hd, %ld, %lld, %zd

Format a short, long, long long, or size_t.

%^16d, %^32d, %^64d

Format a 16-, 32-, or 64-bit integer.

%o, %u, %x, %X

Format an unsigned integer in octal, decimal, or hexadecimal (with lower-case or upper-case letters).

%s

Format a C string (const char *). The alternate form %#s calls String::printable() on the input string. Both %#s and the alternate form %'s ensure that no part of the string is mistaken for an error annotation.

%c

Format a character. Prints a C-like escape if the input character isn't printable ASCII.

%p

Format a pointer as a hexadecimal value.

%e, %E, %f, %F, %g, %G

Format a double (user-level only).

%p{...}

Call a user-provided conversion function. For example, %p{ip_ptr} reads an IPAddress * argument from the argument list, and formats the pointed-to address using IPAddress::unparse().

%%

Format a literal % character.

%<

Format a left quote string. Usually prints a single quote.

%>

Format a right quote string. Usually prints a single quote.

%,

Format an apostrophe string. Usually prints a single quote.

Definition at line 757 of file error.cc.

References fmt, s, va_end, va_start, val, and vxformat().

◆ xmessage() [1/5]

int ErrorHandler::xmessage ( const String anno,
const char *  fmt,
va_list  val 
)
inline

Format and print an error message, adding annotations.

Parameters
annoannotations
fmterror message format
valformat arguments

Shorthand for xmessage(anno, vformat(fmt, val)).

Definition at line 237 of file error.hh.

References fmt, vformat(), and xmessage().

◆ xmessage() [2/5]

int ErrorHandler::xmessage ( const String anno,
const String str 
)
inline

Print an error message, adding annotations.

Parameters
annoannotations
strerror message

Shorthand for xmessage(combine_anno(str, anno)).

Definition at line 228 of file error.hh.

References combine_anno(), str, and xmessage().

◆ xmessage() [3/5]

int ErrorHandler::xmessage ( const String landmark,
const String anno,
const char *  fmt,
va_list  val 
)
inline

Format and print an error message, adding landmark and other annotations.

Parameters
landmarklandmark annotation
annoadditional annotations
fmterror message format
valformat arguments

Shorthand for xmessage(landmark, anno, vformat(fmt, val)).

Definition at line 260 of file error.hh.

References fmt, landmark(), vformat(), and xmessage().

◆ xmessage() [4/5]

int ErrorHandler::xmessage ( const String landmark,
const String anno,
const String str 
)
inline

Print an error message, adding landmark and other annotations.

Parameters
landmarklandmark annotation
annoadditional annotations
strerror message

Shorthand for xmessage(combine_anno(anno, make_landmark_anno(landmark)), str).

Definition at line 247 of file error.hh.

References combine_anno(), landmark(), make_landmark_anno(), str, and xmessage().

◆ xmessage() [5/5]

int ErrorHandler::xmessage ( const String str)

Print an annotated error message.

Returns
ok_result if the minimum error level was el_notice or higher, otherwise error_result

This function drives the virtual functions actually responsible for error message decoration and printing. It passes str to decorate(), separates the result into lines, calls emit() for each line, and calls account() with the minimum error level of any line.

Most users will call shorthand functions like error(), warning(), or lmessage(), which add relevant annotations to the message.

Definition at line 891 of file error.cc.

References account(), decorate(), el_warning, emit(), end, error_result, find(), cutout::l, nl, ok_result, parse_anno(), s, str, and xstr.

Referenced by debug(), error(), Efont::MultipleMasterSpace::error(), fatal(), ldebug(), Efont::AfmReader::lerror(), Efont::AmfmReader::lerror(), lerror(), lfatal(), lmessage(), Efont::AfmReader::lwarning(), Efont::AmfmReader::lwarning(), lwarning(), message(), read_file(), usage_error(), warning(), and xmessage().

Member Data Documentation

◆ _nerrors

int ErrorHandler::_nerrors
private

Definition at line 574 of file error.hh.

Referenced by account(), clear(), and nerrors().

◆ e_abort

const char ErrorHandler::e_abort = "<-999>"
static

Error level indicators.

Definition at line 110 of file error.hh.

◆ e_alert

const char ErrorHandler::e_alert = "<1>"
static

Definition at line 113 of file error.hh.

◆ e_critical

const char ErrorHandler::e_critical = "<2>"
static

Definition at line 114 of file error.hh.

◆ e_debug

const char ErrorHandler::e_debug = "<7>"
static

Definition at line 120 of file error.hh.

Referenced by debug(), and ldebug().

◆ e_emergency

const char ErrorHandler::e_emergency = "<0>"
static

Definition at line 112 of file error.hh.

◆ e_error

const char ErrorHandler::e_error = "<3>"
static

◆ e_fatal

const char ErrorHandler::e_fatal = "<-1>"
static

Definition at line 111 of file error.hh.

Referenced by fatal(), and lfatal().

◆ e_info

const char ErrorHandler::e_info = "<6>"
static

Definition at line 119 of file error.hh.

Referenced by lmessage(), and message().

◆ e_notice

const char ErrorHandler::e_notice = "<5>"
static

Definition at line 118 of file error.hh.

◆ e_warning

const char ErrorHandler::e_warning = "<4>"
static

Definition at line 116 of file error.hh.

Referenced by Efont::AfmReader::lwarning(), Efont::AmfmReader::lwarning(), and read_file().

◆ e_warning_annotated

const char ErrorHandler::e_warning_annotated = "<4>warning: "
static

Definition at line 117 of file error.hh.

Referenced by lwarning(), and warning().

◆ error_result

const int ErrorHandler::error_result = -EINVAL
static

<5> and above

Equals -EINVAL, used for error

Definition at line 174 of file error.hh.

Referenced by xmessage().

◆ ok_result

const int ErrorHandler::ok_result = 0
static

Equals 0, used for error levels

Definition at line 172 of file error.hh.

Referenced by xmessage().

◆ the_default_handler

ErrorHandler * ErrorHandler::the_default_handler = 0
staticprivate

Definition at line 576 of file error.hh.

Referenced by default_handler(), set_default_handler(), static_cleanup(), and static_initialize().

◆ the_silent_handler

ErrorHandler * ErrorHandler::the_silent_handler = 0
staticprivate

Definition at line 577 of file error.hh.

Referenced by silent_handler(), static_cleanup(), and static_initialize().


The documentation for this class was generated from the following files: