Coverage Report

Created: 2025-11-24 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qpdf/include/qpdf/QPDFSystemError.hh
Line
Count
Source
1
// Copyright (c) 2005-2021 Jay Berkenbilt
2
// Copyright (c) 2022-2025 Jay Berkenbilt and Manfred Holger
3
//
4
// This file is part of qpdf.
5
//
6
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7
// in compliance with the License. You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software distributed under the License
12
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13
// or implied. See the License for the specific language governing permissions and limitations under
14
// the License.
15
//
16
// Versions of qpdf prior to version 7 were released under the terms of version 2.0 of the Artistic
17
// License. At your option, you may continue to consider qpdf to be licensed under those terms.
18
// Please see the manual for additional information.
19
20
#ifndef QPDFSYSTEMERROR_HH
21
#define QPDFSYSTEMERROR_HH
22
23
#include <qpdf/Constants.h>
24
#include <qpdf/DLL.h>
25
#include <qpdf/Types.h>
26
27
#include <stdexcept>
28
#include <string>
29
30
class QPDF_DLL_CLASS QPDFSystemError: public std::runtime_error
31
{
32
  public:
33
    QPDF_DLL
34
    QPDFSystemError(std::string const& description, int system_errno);
35
36
0
    ~QPDFSystemError() noexcept override = default;
37
38
    // To get a complete error string, call what(), provided by std::exception.  The accessors below
39
    // return the original values used to create the exception.
40
41
    QPDF_DLL
42
    std::string const& getDescription() const;
43
    QPDF_DLL
44
    int getErrno() const;
45
46
  private:
47
    QPDF_DLL_PRIVATE
48
    static std::string createWhat(std::string const& description, int system_errno);
49
50
    // This class does not use the Members pattern to avoid needless memory allocations during
51
    // exception handling.
52
53
    std::string description;
54
    int system_errno;
55
};
56
57
#endif // QPDFSYSTEMERROR_HH