2008-04-29 12:55:25 +00:00
|
|
|
#include <qpdf/QPDFExc.hh>
|
2022-02-04 21:31:31 +00:00
|
|
|
|
2009-10-19 23:09:19 +00:00
|
|
|
QPDFExc::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-19 23:09:19 +00:00
|
|
|
std::runtime_error(createWhat(filename, object, offset, message)),
|
|
|
|
error_code(error_code),
|
|
|
|
filename(filename),
|
|
|
|
object(object),
|
|
|
|
offset(offset),
|
|
|
|
message(message)
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-10-19 23:09:19 +00:00
|
|
|
std::string
|
|
|
|
QPDFExc::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)
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
2009-10-19 23:09:19 +00:00
|
|
|
std::string result;
|
|
|
|
if (!filename.empty()) {
|
2022-02-08 14:18:08 +00:00
|
|
|
result += filename;
|
2009-10-19 23:09:19 +00:00
|
|
|
}
|
|
|
|
if (!(object.empty() && offset == 0)) {
|
2018-02-16 22:25:27 +00:00
|
|
|
if (!filename.empty()) {
|
|
|
|
result += " (";
|
|
|
|
}
|
2022-02-08 14:18:08 +00:00
|
|
|
if (!object.empty()) {
|
|
|
|
result += object;
|
|
|
|
if (offset > 0) {
|
|
|
|
result += ", ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (offset > 0) {
|
2022-09-21 16:49:21 +00:00
|
|
|
result += "offset " + std::to_string(offset);
|
2022-02-08 14:18:08 +00:00
|
|
|
}
|
2018-02-16 22:25:27 +00:00
|
|
|
if (!filename.empty()) {
|
|
|
|
result += ")";
|
|
|
|
}
|
2009-10-19 23:09:19 +00:00
|
|
|
}
|
|
|
|
if (!result.empty()) {
|
2022-02-08 14:18:08 +00:00
|
|
|
result += ": ";
|
2009-10-19 23:09:19 +00:00
|
|
|
}
|
|
|
|
result += message;
|
|
|
|
return result;
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
2009-10-20 00:24:44 +00:00
|
|
|
|
|
|
|
qpdf_error_code_e
|
|
|
|
QPDFExc::getErrorCode() const
|
|
|
|
{
|
|
|
|
return this->error_code;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string const&
|
|
|
|
QPDFExc::getFilename() const
|
|
|
|
{
|
|
|
|
return this->filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string const&
|
|
|
|
QPDFExc::getObject() const
|
|
|
|
{
|
|
|
|
return this->object;
|
|
|
|
}
|
|
|
|
|
2012-06-21 23:32:21 +00:00
|
|
|
qpdf_offset_t
|
2009-10-20 00:24:44 +00:00
|
|
|
QPDFExc::getFilePosition() const
|
|
|
|
{
|
|
|
|
return this->offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string const&
|
|
|
|
QPDFExc::getMessageDetail() const
|
|
|
|
{
|
|
|
|
return this->message;
|
|
|
|
}
|