PoDoFo  1.0.0-dev
Public Member Functions | Static Public Member Functions | List of all members
PoDoFo::PdfError Class Referencefinal

The error handling class of the PoDoFo library. More...

#include <PdfError.h>

Inherits std::exception.

Public Member Functions

 PdfError (PdfErrorCode code, std::string filepath, unsigned line, std::string information={ })
 Create a PdfError object with a given error code. More...
 
 PdfError (const PdfError &rhs)=default
 Copy constructor. More...
 
PdfErroroperator= (const PdfError &rhs)=default
 Assignment operator. More...
 
bool operator== (PdfErrorCode code)
 Compares this PdfError object with an error code. More...
 
bool operator!= (PdfErrorCode code)
 Compares this PdfError object with an error code. More...
 
std::string_view GetName () const
 
PdfErrorCode GetCode () const
 Return the error code of this object. More...
 
const PdErrorInfoStack & GetCallStack () const
 Get access to the internal callstack of this error. More...
 
void PrintErrorMsg () const
 Print an error message to stderr. More...
 
const char * what () const noexcept override
 Obtain error description. More...
 

Static Public Member Functions

static std::string_view ErrorName (PdfErrorCode code)
 Get the name for a certain error code. More...
 
static std::string_view ErrorMessage (PdfErrorCode code)
 Get the error message for a certain error code. More...
 

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 PdfErrorCode, which are all codes PoDoFo uses (except the first and last one).

Constructor & Destructor Documentation

◆ PdfError() [1/2]

PdfError::PdfError ( PdfErrorCode  code,
std::string  filepath,
unsigned  line,
std::string  information = { } 
)

Create a PdfError object with a given error code.

Parameters
codethe error code of this object
filepaththe 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() [2/2]

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

Copy constructor.

Parameters
rhscopy the contents of rhs into this object

Member Function Documentation

◆ ErrorMessage()

string_view 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()

string_view 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.

◆ GetCallStack()

const PdErrorInfoStack& PoDoFo::PdfError::GetCallStack ( ) const
inline

Get access to the internal callstack of this error.

Returns
the callstack deque of PdfErrorInfo objects.

◆ GetCode()

PdfErrorCode PoDoFo::PdfError::GetCode ( ) const
inline

Return the error code of this object.

Returns
the error code of 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 a different error code.

◆ operator=()

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

Assignment operator.

Parameters
rhsanother PdfError object
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.

◆ what()

const char * PdfError::what ( ) const
overridenoexcept

Obtain error description.

Returns
a C string describing the error.

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