PoDoFo 1.2.0
Loading...
Searching...
No Matches
PdfError.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006 Dominik Seichter <domseichter@web.de>
2// SPDX-FileCopyrightText: 2020 Francesco Pretto <ceztko@gmail.com>
3// SPDX-License-Identifier: LGPL-2.0-or-later OR MPL-2.0
4
5#ifndef PDF_ERROR_H
6#define PDF_ERROR_H
7
9
12
13namespace PoDoFo {
14
76
77class PODOFO_API PdfErrorInfo final
78{
79public:
80 PdfErrorInfo(std::string filepath, unsigned line, std::string info);
81 PdfErrorInfo(const PdfErrorInfo& rhs) = default;
82 PdfErrorInfo& operator=(const PdfErrorInfo& rhs) = default;
83
84public:
87 std::string_view GetFilePath() const;
88 const std::string& GetFullFilePath() const { return m_FilePath; }
89 inline unsigned GetLine() const { return m_Line; }
90 inline const std::string& GetInformation() const { return m_Info; }
91
92private:
93 unsigned m_Line;
94 std::string m_FilePath;
95 std::string m_Info;
96};
97
98using PdErrorInfoStack = std::deque<PdfErrorInfo>;
99
109class PODOFO_API PdfError final : public std::exception
110{
111 PODOFO_PRIVATE_FRIEND(void AddToCallStack(PdfError& err, std::string filepath, unsigned line, std::string information));
112
113public:
121 PdfError(PdfErrorCode code, std::string filepath, unsigned line,
122 std::string information = { });
123
126 PdfError(const PdfError& rhs) = default;
127
131 PdfError& operator=(const PdfError& rhs) = default;
132
137 bool operator==(PdfErrorCode code);
138
143 bool operator!=(PdfErrorCode code);
144
145 std::string_view GetName() const;
146
149 inline PdfErrorCode GetCode() const { return m_Code; }
150
153 inline const PdErrorInfoStack& GetCallStack() const { return m_CallStack; }
154
157 void PrintErrorMsg() const;
158
161 const char* what() const noexcept override;
162
163public:
167 static std::string_view ErrorName(PdfErrorCode code);
168
173 static std::string_view ErrorMessage(PdfErrorCode code);
174
175private:
188 void AddToCallStack(std::string&& filepath, unsigned line, std::string&& information);
189
190 void initFullDescription();
191
192private:
193 PdfErrorCode m_Code;
194 PdErrorInfoStack m_CallStack;
195 std::string m_FullDescription;
196};
197
198};
199
200#endif // PDF_ERROR_H
This file should be included as the FIRST file in every header of PoDoFo lib.
The error handling class of the PoDoFo library.
Definition PdfError.h:110
const PdErrorInfoStack & GetCallStack() const
Get access to the internal callstack of this error.
Definition PdfError.h:153
PdfErrorCode GetCode() const
Return the error code of this object.
Definition PdfError.h:149
PdfError & operator=(const PdfError &rhs)=default
Assignment operator.
PdfError(const PdfError &rhs)=default
Copy constructor.
Convenient type for char array storage and/or buffer with std::string compatibility.
Definition basetypes.h:30
All classes, functions, types and enums of PoDoFo are members of these namespace.
Definition basetypes.h:13
PdfErrorCode
Error Code enum values which are used in PdfError to describe the error.
Definition PdfError.h:22
@ InvalidKey
The specified key is invalid.
@ InvalidXRef
The XRef table is invalid.
@ BrokenFile
The file content is broken.
@ InvalidXRefStream
A XRef stream is invalid.
@ InvalidEnumValue
An invalid enum value was specified.
@ ChangeOnImmutable
Changing values on immutable objects is not allowed.
@ XmpMetadataError
Error while creating or reading XMP metadata.
@ MaxRecursionReached
Reached maximum recursion depth.
@ FileNotFound
A file was not found or cannot be opened.
@ InvalidHandle
Unexpected null pointer or invalid state.
@ InvalidDataType
The passed datatype is invalid or was not recognized.
@ InvalidContentStream
The content stream is invalid due to mismatched context pairing or other problems.
@ IOError
Tried to do something unsupported to an I/O device like seek a non-seekable input device.
@ InvalidStrokeStyle
Invalid stroke style during drawing.
@ FlateError
Error in zlib.
@ UnsupportedFontFormat
This font format is not supported by PoDoFo.
@ InvalidTrailer
The PDF file has no or an invalid trailer.
@ InvalidObject
Invalid object or none was found.
@ UnsupportedFilter
The requested filter is not yet implemented.
@ UnsupportedImageFormat
This image format is not supported by PoDoFo.
@ FreeTypeError
Error in FreeType.
@ InternalLogic
An internal sanity check or assertion failed.
@ ItemAlreadyPresent
An item to be inserted is already in this container.
@ InvalidNumber
A number was expected in the PDF file, but the read string is no number.
@ InvalidPassword
The password used to open the PDF file was invalid.
@ InvalidPredictor
Invalid or unimplemented predictor.
@ NotImplemented
This feature is currently not implemented.
@ OpenSSLError
OpenSSL error.
@ UnsupportedPixelFormat
This pixel format is not supported by PoDoFo.
@ InvalidName
The specified Name is not valid in this context.
@ InvalidFontData
The font file is invalid.
@ OutOfMemory
Not enough memory to complete an operation.
@ ObjectNotFound
An object was requested but was not found.
@ WrongDestinationType
The requested field is not available for the given destination type.
@ InvalidEncoding
Invalid encoding information.
@ InvalidPDF
The file is no PDF file.
@ InvalidStream
The stream is invalid.
@ InvalidInput
Invalid input.
@ CannotConvertColor
This color format cannot be converted.
@ InvalidEncryptionDict
The encryption dictionary is invalid or misses a required key.
@ InvalidEOFToken
The PDF file has no or an invalid EOF marker.
@ ValueOutOfRange
The specified memory is out of the allowed range.
@ UnsupportedOperation
Unsupported operation.
@ UnexpectedEOF
End of file was reached but data was expected.