OEErrorHandler

class OEErrorHandler

This class represents OEErrorHandler.

The OEErrorHandler class is used to define the behavior of the OEThrow error handler. All diagnostic output, including error, warning and informational messages, generated by the OpenEye libraries are emitted via OEThrow. The OEErrorHandler class defines how these messages are emitted, but also how the user can redirect and/or intercept these messages.

Constructors

OEErrorHandler()

Default constructor that creates an OEErrorHandlerImplBase that it owns and writes output to stderr.

OEErrorHandler(OEErrorHandler &rhs)

Copy constructor.

Note

OEErrorHandlerImplBase::CreateCopy will only be called by the copy constructor if the right-hand-side owns the OEErrorHandlerImplBase. This is why the right-hand-side argument is non-const.

operator=

OEErrorHandler &operator=(OEErrorHandler &rhs)

Assignment operator.

Note

OEErrorHandlerImplBase::CreateCopy will only be called by operator= if the right-hand-side owns the OEErrorHandlerImplBase. This is why the right-hand-side argument is non-const.

Clear

void Clear()

Reset all the counts returned by OEErrorHandler::Count to zero.

Count

unsigned int Count(unsigned int level=0) const

Returns the number of messages already written at the given level. The constant level should be drawn from the OEErrorLevel namespace. If level is zero, the default, the sum of all error level counts is returned.

Debug

void Debug(const std::string &)
void Debug(const char *format, ...)

Writes debugging messages to the OEErrorHandler. By default, these message will not appear, OEErrorHandler::SetLevel should be set to OEErrorLevel::Debug or below to make them appear.

Error

void Error(const std::string &)
void Error(const char *format, ...)

Writes error messages to the OEErrorHandler. Depending upon the value of the OEErrorHandler’s ‘strict’ property (see OEErrorHandler::GetStrict and OEErrorHandler::SetStrict), these diagnostics are forwarded to either the OEErrorHandler::Fatal or OEErrorHandler::Warning methods.

Fatal

void Fatal(const std::string &)
void Fatal(const char *format, ...)

Writes fatal error messages to the OEErrorHandler.

GetHandlerImpl

OEErrorHandlerImplBase *GetHandlerImpl()

Returns the OEErrorHandlerImplBase error handler that is used to handle messages. The default error handler writes output to stderr. The error handler can be changed by calling the OEErrorHandler::SetHandlerImpl method.

GetLevel

unsigned int GetLevel() const

Returns a constant from the OEErrorLevel namespace indicating the current level of messages that should make it to the output stream. The default is OEErrorLevel::Default, that will output messages of OEErrorHandler::Info or higher.

Warning

All threads, including the main thread, will start out at the OEErrorLevel::Default level. OEErrorHandler::SetLevel will only change the level for the current thread.

GetStrict

bool GetStrict() const

Returns the ‘strict’ property of the OEErrorHandler. When the OEErrorHandler is strict, all error messages written via the OEErrorHandler::Error methods are treated as fatal, and handled like those passed to OEErrorHandler::Fatal. When the OEErrorHandler is not strict, error messages written via OEErrorHandler::Error are treated like those to OEErrorHandler::Warning. The strict property of an OEErrorHandler can be set using the OEErrorHandler::SetStrict method.

Info

void Info(const std::string &)
void Info(const char *format, ...)

Writes an informational messages to the OEErrorHandler.

Msg

void Msg(unsigned int level, const std::string &)
void Msg(unsigned int level, const char *format, ...)

Write a message at any level. The level constant should be drawn from the OEErrorLevel namespace.

SetHandlerImpl

void SetHandlerImpl(OEErrorHandlerImplBase *ptr, bool owned)

Use a different implementation of OEErrorHandlerImplBase to handle error messages. The ownership is determined by the owned flag, which is always false in any other language but C++.

This method allows a user to completely redefine how the OpenEye toolkits handle error messages by declaring a new subclass of OEErrorHandlerImplBase and defining the OEErrorHandlerImplBase::Msg to have the desired behavior.

SetLevel

void SetLevel(unsigned int errLevel)

Controls whether a message passed to the error handler will make it to the output stream. Values greater than errLevel from the OEErrorLevel namespace will be sent to the output stream.

Warning

This method will only change the error level for the current thread. Child threads will not inherit the parent thread error level.

SetOutputStream

void SetOutputStream(OEPlatform::oeostream &ofs)

Sets the output stream (oeostream) that diagnostic messages are written to when no custom error handler has been specified. By default, all messages are written to OEPlatform::oeerr. This function can be used to redirect this output to either a file stream (oeofstream) or a string stream (oeosstream).

SetStrict

void SetStrict(bool strict)

Sets the ‘strict’ property of the OEErrorHandler. When the OEErrorHandler is strict, all error messages written via the OEErrorHandler::Error methods are treated as fatal, and handled like those passed to OEErrorHandler::Fatal. When the OEErrorHandler is not strict, error messages written via OEErrorHandler::Error are treated like those to OEErrorHandler::Warning. The strict property of an OEErrorHandler can be retrieved by using the OEErrorHandler::GetStrict method.

Usage

void Usage(const std::string &)
void Usage(const char *format, ...)

Writes usage (warning) messages to the OEErrorHandler.

Verbose

void Verbose(const std::string &)
void Verbose(const char *format, ...)

Writes messages with the OEErrorLevel::Verbose error message level to the OEErrorHandler. By default, these messages will not appear.

Warning

void Warning(const std::string &)
void Warning(const char *format, ...)

Writes warning messages to the OEErrorHandler.