pdfmm 0.9.20
Public Member Functions | Static Public Member Functions | List of all members
mm::PdfError Class Referencefinal

#include <PdfError.h>

Public Member Functions

 PdfError ()
 
 PdfError (PdfErrorCode code, std::string file, unsigned line, std::string information)
 
 PdfError (const PdfError &rhs)=default
 
PdfErroroperator= (const PdfError &rhs)=default
 
PdfErroroperator= (const PdfErrorCode &code)
 
bool operator== (PdfErrorCode code)
 
bool operator!= (PdfErrorCode code)
 
PdfErrorCode GetError () const
 
const PdErrorInfoQueue & GetCallstack () const
 
void AddToCallstack (std::string file, unsigned line, std::string information)
 
bool IsError () const
 
void PrintErrorMsg () const
 
const char * what () const
 

Static Public Member Functions

static void SetLogMessageCallback (const LogMessageCallback &logMessageCallback)
 
static const char * ErrorName (PdfErrorCode code)
 
static const char * ErrorMessage (PdfErrorCode code)
 
static void LogMessage (LogSeverity logSeverity, const std::string_view &msg)
 
static void SetMinLoggingSeverity (LogSeverity logSeverity)
 
static bool IsLoggingSeverityEnabled (LogSeverity logSeverity)
 

Detailed Description

The error handling class of the pdfmm 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 PdfErrorCode, which are all codes pdfmm uses (except the first and last one).

Constructor & Destructor Documentation

◆ PdfError() [1/3]

PdfError::PdfError ( )

Create a PdfError object initialized to PdfErrorCode::Ok.

◆ PdfError() [2/3]

PdfError::PdfError ( PdfErrorCode  code,
std::string  file,
unsigned  line,
std::string  information 
)

Create a PdfError object with a given error code.

Parameters
codethe error code of this object
filethe 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.
informationadditional information on this error

◆ PdfError() [3/3]

mm::PdfError::PdfError ( const PdfError rhs)
default

Copy constructor

Parameters
rhscopy the contents of rhs into this object

Member Function Documentation

◆ AddToCallstack()

void PdfError::AddToCallstack ( std::string  file,
unsigned  line,
std::string  information 
)

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
filethe filename of the source file causing the error or nullptr. 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.
informationadditional information on the error, e.g. how to fix the error. This string is intended to be shown to the user.

◆ ErrorMessage()

const char * PdfError::ErrorMessage ( PdfErrorCode  code)
static

Get the error message for a certain error code.

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

◆ ErrorName()

const char * PdfError::ErrorName ( PdfErrorCode  code)
static

Get the name for a certain error code.

Returns
the name or nullptr 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 pdfmm.

< This image format is not supported by pdfmm.

< This color format cannot be converted.

◆ GetCallstack()

const PdErrorInfoQueue & mm::PdfError::GetCallstack ( ) const
inline

Get access to the internal callstack of this error.

Returns
the callstack deque of PdfErrorInfo objects.

◆ GetError()

PdfErrorCode mm::PdfError::GetError ( ) const
inline

Return the error code of this object.

Returns
the error code of this object

◆ IsError()

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

◆ IsLoggingSeverityEnabled()

bool PdfError::IsLoggingSeverityEnabled ( LogSeverity  logSeverity)
static

The if the given logging severity enabled or not

◆ LogMessage()

static void mm::PdfError::LogMessage ( LogSeverity  logSeverity,
const std::string_view &  msg 
)
static

Log a message to the logging system defined for pdfmm.

Parameters
logSeveritythe severity of the log message
msgthe message to be logged

◆ operator!=()

bool PdfError::operator!= ( PdfErrorCode  code)

Compares this PdfError object with an error code

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

◆ operator=() [1/2]

PdfError & mm::PdfError::operator= ( const PdfError rhs)
default

Assignment operator

Parameters
rhsanother PdfError object
Returns
this object

◆ operator=() [2/2]

PdfError & PdfError::operator= ( const PdfErrorCode code)

Overloaded assignment operator

Parameters
codea PdfErrorCode code
Returns
this object

◆ operator==()

bool PdfError::operator== ( PdfErrorCode  code)

Compares this PdfError object with an error code

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

◆ PrintErrorMsg()

void PdfError::PrintErrorMsg ( ) const

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

◆ SetLogMessageCallback()

void PdfError::SetLogMessageCallback ( const LogMessageCallback &  logMessageCallback)
static

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

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

◆ SetMinLoggingSeverity()

void PdfError::SetMinLoggingSeverity ( LogSeverity  logSeverity)
static

Set the minimum logging severity

◆ what()

const char * PdfError::what ( ) const

Obtain error description.

Returns
a C string describing the error.