2023-02-25 19:18:13 +00:00
|
|
|
// Copyright (c) 2005-2023 Jay Berkenbilt
|
2008-04-29 12:55:25 +00:00
|
|
|
//
|
2017-09-14 16:44:31 +00:00
|
|
|
// This file is part of qpdf.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
|
|
// in compliance with the License. You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
|
|
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
|
|
// or implied. See the License for the specific language governing permissions and limitations under
|
|
|
|
// the License.
|
|
|
|
//
|
|
|
|
// Versions of qpdf prior to version 7 were released under the terms of version 2.0 of the Artistic
|
|
|
|
// License. At your option, you may continue to consider qpdf to be licensed under those terms.
|
|
|
|
// Please see the manual for additional information.
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#ifndef QPDFEXC_HH
|
|
|
|
#define QPDFEXC_HH
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2012-06-21 17:47:41 +00:00
|
|
|
#include <qpdf/Constants.h>
|
2009-10-19 20:17:14 +00:00
|
|
|
#include <qpdf/DLL.h>
|
2012-06-20 14:54:07 +00:00
|
|
|
#include <qpdf/Types.h>
|
2019-06-22 01:32:47 +00:00
|
|
|
|
2009-10-20 02:35:28 +00:00
|
|
|
#include <stdexcept>
|
2013-10-29 00:59:58 +00:00
|
|
|
#include <string>
|
2008-04-29 12:55:25 +00:00
|
|
|
|
2019-06-22 00:27:31 +00:00
|
|
|
class QPDF_DLL_CLASS QPDFExc: public std::runtime_error
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2009-10-19 23:09:19 +00:00
|
|
|
QPDFExc(
|
|
|
|
qpdf_error_code_e error_code,
|
2022-02-08 14:18:08 +00:00
|
|
|
std::string const& filename,
|
|
|
|
std::string const& object,
|
|
|
|
qpdf_offset_t offset,
|
|
|
|
std::string const& message);
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2023-06-01 14:21:32 +00:00
|
|
|
~QPDFExc() noexcept override = default;
|
2009-10-19 23:09:19 +00:00
|
|
|
|
|
|
|
// To get a complete error string, call what(), provided by std::exception. The accessors below
|
|
|
|
// return the original values used to create the exception. Only the error code and message are
|
|
|
|
// guaranteed to have non-zero/empty values.
|
|
|
|
|
|
|
|
// There is no lookup code that maps numeric error codes into strings. The numeric error code
|
|
|
|
// is just another way to get at the underlying issue, but it is more programmer-friendly than
|
|
|
|
// trying to parse a string that is subject to change.
|
|
|
|
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2009-10-19 23:09:19 +00:00
|
|
|
qpdf_error_code_e getErrorCode() const;
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2009-10-19 23:09:19 +00:00
|
|
|
std::string const& getFilename() const;
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2009-10-19 23:09:19 +00:00
|
|
|
std::string const& getObject() const;
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2012-06-21 23:32:21 +00:00
|
|
|
qpdf_offset_t getFilePosition() const;
|
2009-10-21 01:45:13 +00:00
|
|
|
QPDF_DLL
|
2009-10-20 00:24:44 +00:00
|
|
|
std::string const& getMessageDetail() const;
|
2009-10-19 23:09:19 +00:00
|
|
|
|
|
|
|
private:
|
2022-04-10 17:29:10 +00:00
|
|
|
QPDF_DLL_PRIVATE
|
2009-10-19 23:09:19 +00:00
|
|
|
static std::string createWhat(
|
|
|
|
std::string const& filename,
|
2022-02-08 14:18:08 +00:00
|
|
|
std::string const& object,
|
|
|
|
qpdf_offset_t offset,
|
|
|
|
std::string const& message);
|
2009-10-19 23:09:19 +00:00
|
|
|
|
2019-06-22 01:32:47 +00:00
|
|
|
// This class does not use the Members pattern to avoid needless memory allocations during
|
|
|
|
// exception handling.
|
|
|
|
|
2009-10-19 23:09:19 +00:00
|
|
|
qpdf_error_code_e error_code;
|
|
|
|
std::string filename;
|
|
|
|
std::string object;
|
2012-06-21 23:32:21 +00:00
|
|
|
qpdf_offset_t offset;
|
2009-10-19 23:09:19 +00:00
|
|
|
std::string message;
|
2008-04-29 12:55:25 +00:00
|
|
|
};
|
|
|
|
|
2018-08-12 18:07:22 +00:00
|
|
|
#endif // QPDFEXC_HH
|