Coverage Report

Created: 2026-10-17 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qpdf/libqpdf/QPDFExc.cc
Line
Count
Source
1
#include <qpdf/QPDFExc.hh>
2
3
QPDFExc::QPDFExc(
4
    qpdf_error_code_e error_code,
5
    std::string const& filename,
6
    std::string const& object,
7
    qpdf_offset_t offset,
8
    std::string const& message) :
9
554k
    std::runtime_error(createWhat(filename, object, (offset ? offset : -1), message)),
10
554k
    error_code(error_code),
11
554k
    filename(filename),
12
554k
    object(object),
13
554k
    offset(offset ? offset : -1),
14
554k
    message(message)
15
554k
{
16
554k
}
17
18
QPDFExc::QPDFExc(
19
    qpdf_error_code_e error_code,
20
    std::string const& filename,
21
    std::string const& object,
22
    qpdf_offset_t offset,
23
    std::string const& message,
24
    bool zero_offset_valid) :
25
403k
    std::runtime_error(
26
403k
        createWhat(filename, object, (offset || zero_offset_valid ? offset : -1), message)),
27
403k
    error_code(error_code),
28
403k
    filename(filename),
29
403k
    object(object),
30
403k
    offset(offset || zero_offset_valid ? offset : -1),
31
403k
    message(message)
32
403k
{
33
403k
}
34
35
std::string
36
QPDFExc::createWhat(
37
    std::string const& filename,
38
    std::string const& object,
39
    qpdf_offset_t offset,
40
    std::string const& message)
41
957k
{
42
957k
    std::string result;
43
957k
    if (!filename.empty()) {
44
860k
        result += filename;
45
860k
    }
46
957k
    if (!(object.empty() && offset < 0)) {
47
824k
        if (!filename.empty()) {
48
727k
            result += " (";
49
727k
        }
50
824k
        if (!object.empty()) {
51
768k
            result += object;
52
768k
            if (offset >= 0) {
53
670k
                result += ", ";
54
670k
            }
55
768k
        }
56
824k
        if (offset >= 0) {
57
727k
            result += "offset " + std::to_string(offset);
58
727k
        }
59
824k
        if (!filename.empty()) {
60
727k
            result += ")";
61
727k
        }
62
824k
    }
63
957k
    if (!result.empty()) {
64
957k
        result += ": ";
65
957k
    }
66
957k
    result += message;
67
957k
    return result;
68
957k
}
69
70
qpdf_error_code_e
71
QPDFExc::getErrorCode() const
72
0
{
73
0
    return this->error_code;
74
0
}
75
76
std::string const&
77
QPDFExc::getFilename() const
78
0
{
79
0
    return this->filename;
80
0
}
81
82
std::string const&
83
QPDFExc::getObject() const
84
0
{
85
0
    return this->object;
86
0
}
87
88
qpdf_offset_t
89
QPDFExc::getFilePosition() const
90
0
{
91
0
    return offset < 0 ? 0 : offset;
92
0
}
93
94
std::string const&
95
QPDFExc::getMessageDetail() const
96
0
{
97
0
    return this->message;
98
0
}