PoDoFo  0.9.6
Public Member Functions | Static Public Member Functions | List of all members
PoDoFo::PdfError Class Reference

#include <PdfError.h>

Public Member Functions

 PdfError ()
 
 PdfError (const EPdfError &eCode, const char *pszFile=NULL, int line=0, const char *pszInformation=NULL)
 
 PdfError (const EPdfError &eCode, const char *pszFile, int line, std::string sInformation)
 
 PdfError (const PdfError &rhs)
 
const PdfErroroperator= (const PdfError &rhs)
 
const PdfErroroperator= (const EPdfError &eCode)
 
bool operator== (const PdfError &rhs)
 
bool operator== (const EPdfError &eCode)
 
bool operator!= (const PdfError &rhs)
 
bool operator!= (const EPdfError &eCode)
 
EPdfError GetError () const
 
const TDequeErrorInfo & GetCallstack () const
 
void SetError (const EPdfError &eCode, const char *pszFile, int line, std::string sInformation)
 
void SetError (const EPdfError &eCode, const char *pszFile=NULL, int line=0, const char *pszInformation=NULL)
 
void SetErrorInformation (const char *pszInformation)
 
void SetErrorInformation (const wchar_t *pszInformation)
 
void AddToCallstack (const char *pszFile=NULL, int line=0, const char *pszInformation=NULL)
 
void AddToCallstack (const char *pszFile, int line, std::string sInformation)
 
bool IsError () const
 
void PrintErrorMsg () const
 
const char * what () const
 

Static Public Member Functions

static LogMessageCallback * SetLogMessageCallback (LogMessageCallback *fLogMessageCallback)
 
static PODOFO_NOTHROW const char * ErrorName (EPdfError eCode)
 
static const char * ErrorMessage (EPdfError eCode)
 
static void LogMessage (ELogSeverity eLogSeverity, const char *pszMsg,...)
 
static void LogMessage (ELogSeverity eLogSeverity, const wchar_t *pszMsg,...)
 
static void EnableLogging (bool bEnable)
 
static bool LoggingEnabled ()
 
static void DebugMessage (const char *pszMsg,...)
 
static void EnableDebug (bool bEnable)
 
static bool DebugEnabled ()
 

Detailed Description

The error handling class of the PoDoFo library. If a method encounters an error, a PdfError object is thrown as a C++ exception.

This class does not inherit from std::exception.

This class also provides meaningful error descriptions for the error codes which are values of the enum EPdfError, which are all codes PoDoFo uses (except the first and last one).

Constructor & Destructor Documentation

◆ PdfError() [1/4]

PoDoFo::PdfError::PdfError ( )

Create a PdfError object initialized to ePdfError_ErrOk.

◆ PdfError() [2/4]

PoDoFo::PdfError::PdfError ( const EPdfError eCode,
const char *  pszFile = NULL,
int  line = 0,
const char *  pszInformation = NULL 
)

Create a PdfError object with a given error code.

Parameters
eCodethe error code of this object
pszFilethe file in which the error has occurred. Use the compiler macro FILE to initialize the field.
linethe line in which the error has occurred. Use the compiler macro LINE to initialize the field.
pszInformationadditional information on this error

◆ PdfError() [3/4]

PoDoFo::PdfError::PdfError ( const EPdfError eCode,
const char *  pszFile,
int  line,
std::string  sInformation 
)
explicit

Create a PdfError object with a given error code.

Parameters
eCodethe error code of this object
pszFilethe file in which the error has occurred. Use the compiler macro FILE to initialize the field.
linethe line in which the error has occurred. Use the compiler macro LINE to initialize the field.
sInformationadditional information on this error

◆ PdfError() [4/4]

PoDoFo::PdfError::PdfError ( const PdfError rhs)

Copy constructor

Parameters
rhscopy the contents of rhs into this object

Member Function Documentation

◆ AddToCallstack() [1/2]

void PoDoFo::PdfError::AddToCallstack ( const char *  pszFile,
int  line,
std::string  sInformation 
)
inline

Add callstack information to an error object. Always call this function if you get an error object but do not handle the error but throw it again.

Parameters
pszFilethe filename of the source file causing the error or NULL. Typically you will use the gcc macro FILE here.
linethe line of source causing the error or 0. Typically you will use the gcc macro LINE here.
sInformationadditional information on the error, e.g. how to fix the error. This string is intended to be shown to the user.

◆ AddToCallstack() [2/2]

void PoDoFo::PdfError::AddToCallstack ( const char *  pszFile = NULL,
int  line = 0,
const char *  pszInformation = NULL 
)
inline

Add callstack information to an error object. Always call this function if you get an error object but do not handle the error but throw it again.

Parameters
pszFilethe filename of the source file causing the error or NULL. Typically you will use the gcc macro FILE here.
linethe line of source causing the error or 0. Typically you will use the gcc macro LINE here.
pszInformationadditional information on the error, e.g. how to fix the error. This string is intended to be shown to the user.

◆ DebugEnabled()

bool PoDoFo::PdfError::DebugEnabled ( )
static

Is the display of debugging messages enabled or not?

◆ DebugMessage()

void PoDoFo::PdfError::DebugMessage ( const char *  pszMsg,
  ... 
)
static

Log a message to the logging system defined for PoDoFo for debugging.

Parameters
pszMsgthe message to be logged

◆ EnableDebug()

void PoDoFo::PdfError::EnableDebug ( bool  bEnable)
static

Enable or disable the display of debugging messages.

Parameters
bEnableenable (true) or disable (false)

◆ EnableLogging()

void PoDoFo::PdfError::EnableLogging ( bool  bEnable)
static

Enable or disable logging.

Parameters
bEnableenable (true) or disable (false)

◆ ErrorMessage()

const char * PoDoFo::PdfError::ErrorMessage ( EPdfError  eCode)
static

Get the error message for a certain error code.

Returns
the error message or NULL if no error message for the specified error code is available.

◆ ErrorName()

const char * PoDoFo::PdfError::ErrorName ( EPdfError  eCode)
static

Get the name for a certain error code.

Returns
the name or NULL if no name for the specified error code is available.

< The encryption dictionary is invalid or misses a required key

< The password used to open the PDF file was invalid

< This font format is not supported by PoDoFO.

< This image format is not supported by PoDoFO.

< This color format cannot be converted.

◆ GetCallstack()

const TDequeErrorInfo & PoDoFo::PdfError::GetCallstack ( ) const
inline

Get access to the internal callstack of this error.

Returns
the callstack deque of PdfErrorInfo objects.

◆ GetError()

EPdfError PoDoFo::PdfError::GetError ( ) const
inline

Return the error code of this object.

Returns
the error code of this object

◆ IsError()

bool PoDoFo::PdfError::IsError ( ) const
inline
Returns
true if an error code was set and false if the error code is ePdfError_ErrOk.

◆ LoggingEnabled()

bool PoDoFo::PdfError::LoggingEnabled ( )
static

Is the display of debugging messages enabled or not?

◆ LogMessage() [1/2]

void PoDoFo::PdfError::LogMessage ( ELogSeverity  eLogSeverity,
const char *  pszMsg,
  ... 
)
static

Log a message to the logging system defined for PoDoFo.

Parameters
eLogSeveritythe severity of the log message
pszMsgthe message to be logged

◆ LogMessage() [2/2]

void PoDoFo::PdfError::LogMessage ( ELogSeverity  eLogSeverity,
const wchar_t *  pszMsg,
  ... 
)
static

Log a message to the logging system defined for PoDoFo.

Parameters
eLogSeveritythe severity of the log message
pszMsgthe message to be logged

◆ operator!=() [1/2]

bool PoDoFo::PdfError::operator!= ( const EPdfError eCode)

Overloaded comparison operator, compares this PdfError object with an error code

Parameters
eCodean error code (value of the enum EPdfError)
Returns
true if this object has a different error code.

◆ operator!=() [2/2]

bool PoDoFo::PdfError::operator!= ( const PdfError rhs)

Comparison operator, compares 2 PdfError objects

Parameters
rhsanother PdfError object
Returns
true if the objects have different error codes.

◆ operator=() [1/2]

const PdfError & PoDoFo::PdfError::operator= ( const EPdfError eCode)

Overloaded assignment operator

Parameters
eCodea EPdfError code
Returns
this object

◆ operator=() [2/2]

const PdfError & PoDoFo::PdfError::operator= ( const PdfError rhs)

Assignment operator

Parameters
rhsanother PdfError object
Returns
this object

◆ operator==() [1/2]

bool PoDoFo::PdfError::operator== ( const EPdfError eCode)

Overloaded comparison operator, compares this PdfError object with an error code

Parameters
eCodean error code (value of the enum EPdfError)
Returns
true if this object has the same error code.

◆ operator==() [2/2]

bool PoDoFo::PdfError::operator== ( const PdfError rhs)

Comparison operator, compares 2 PdfError objects

Parameters
rhsanother PdfError object
Returns
true if both objects have the same error code.

◆ PrintErrorMsg()

void PoDoFo::PdfError::PrintErrorMsg ( ) const

Print an error message to stderr. This includes callstack and extra info, if any of either was set.

◆ SetError() [1/2]

void PoDoFo::PdfError::SetError ( const EPdfError eCode,
const char *  pszFile,
int  line,
std::string  sInformation 
)
inline

Set the error code of this object.

Parameters
eCodethe error code of this object
pszFilethe filename of the source file causing the error or NULL. Typically you will use the gcc macro FILE here.
linethe line of source causing the error or 0. Typically you will use the gcc macro LINE here.
sInformationadditional information on the error. e.g. how to fix the error. This string is intended to be shown to the user.

◆ SetError() [2/2]

void PoDoFo::PdfError::SetError ( const EPdfError eCode,
const char *  pszFile = NULL,
int  line = 0,
const char *  pszInformation = NULL 
)
inline

Set the error code of this object.

Parameters
eCodethe error code of this object
pszFilethe filename of the source file causing the error or NULL. Typically you will use the gcc macro FILE here.
linethe line of source causing the error or 0. Typically you will use the gcc macro LINE here.
pszInformationadditional information on the error, e.g. how to fix the error. This string is intended to be shown to the user.

◆ SetErrorInformation() [1/2]

void PoDoFo::PdfError::SetErrorInformation ( const char *  pszInformation)
inline

Set additional error information.

Parameters
pszInformationadditional information on the error, e.g. how to fix the error. This string is intended to be shown to the user.

◆ SetErrorInformation() [2/2]

void PoDoFo::PdfError::SetErrorInformation ( const wchar_t *  pszInformation)
inline

Set additional error information.

Parameters
pszInformationadditional information on the error, e.g. how to fix the error. This string is intended to be shown to the user.

◆ SetLogMessageCallback()

PdfError::LogMessageCallback * PoDoFo::PdfError::SetLogMessageCallback ( LogMessageCallback *  fLogMessageCallback)
static

Set a global static LogMessageCallback functor to replace stderr output in LogMessageInternal.

Parameters
fLogMessageCallbackthe pointer to the new callback functor object
Returns
the pointer to the previous callback functor object

◆ what()

const char * PoDoFo::PdfError::what ( ) const

Obtain error description.

Returns
a C string describing the error.