2008-04-29 12:55:25 +00:00
|
|
|
#include <qpdf/QPDFExc.hh>
|
2022-02-04 21:31:31 +00:00
|
|
|
|
2008-04-29 12:55:25 +00:00
|
|
|
#include <qpdf/QUtil.hh>
|
|
|
|
|
2022-04-02 21:14:10 +00:00
|
|
|
QPDFExc::QPDFExc(
|
|
|
|
qpdf_error_code_e error_code,
|
|
|
|
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
|
2022-04-02 21:14:10 +00:00
|
|
|
QPDFExc::createWhat(
|
|
|
|
std::string const& filename,
|
|
|
|
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;
|
2022-04-02 21:14:10 +00:00
|
|
|
if (!filename.empty()) {
|
2022-02-08 14:18:08 +00:00
|
|
|
result += filename;
|
2009-10-19 23:09:19 +00:00
|
|
|
}
|
2022-04-02 21:14:10 +00:00
|
|
|
if (!(object.empty() && offset == 0)) {
|
|
|
|
if (!filename.empty()) {
|
2018-02-16 22:25:27 +00:00
|
|
|
result += " (";
|
|
|
|
}
|
2022-04-02 21:14:10 +00:00
|
|
|
if (!object.empty()) {
|
2022-02-08 14:18:08 +00:00
|
|
|
result += object;
|
2022-04-02 21:14:10 +00:00
|
|
|
if (offset > 0) {
|
2022-02-08 14:18:08 +00:00
|
|
|
result += ", ";
|
|
|
|
}
|
|
|
|
}
|
2022-04-02 21:14:10 +00:00
|
|
|
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
|
|
|
}
|
2022-04-02 21:14:10 +00:00
|
|
|
if (!filename.empty()) {
|
2018-02-16 22:25:27 +00:00
|
|
|
result += ")";
|
|
|
|
}
|
2009-10-19 23:09:19 +00:00
|
|
|
}
|
2022-04-02 21:14:10 +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;
|
|
|
|
}
|