2008-04-29 12:55:25 +00:00
|
|
|
#include <qpdf/QPDFExc.hh>
|
|
|
|
#include <qpdf/QUtil.hh>
|
|
|
|
|
2009-10-19 23:09:19 +00:00
|
|
|
QPDFExc::QPDFExc(qpdf_error_code_e error_code,
|
|
|
|
std::string const& filename,
|
|
|
|
std::string const& object,
|
2012-06-21 23:32:21 +00:00
|
|
|
qpdf_offset_t offset,
|
2009-10-19 23:09:19 +00:00
|
|
|
std::string const& message) :
|
|
|
|
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
|
|
|
QPDFExc::~QPDFExc() throw ()
|
2008-04-29 12:55:25 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-10-19 23:09:19 +00:00
|
|
|
std::string
|
|
|
|
QPDFExc::createWhat(std::string const& filename,
|
|
|
|
std::string const& object,
|
2012-06-21 23:32:21 +00:00
|
|
|
qpdf_offset_t offset,
|
2009-10-19 23:09:19 +00:00
|
|
|
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())
|
|
|
|
{
|
|
|
|
result += filename;
|
|
|
|
}
|
|
|
|
if (! (object.empty() && offset == 0))
|
|
|
|
{
|
2018-02-16 22:25:27 +00:00
|
|
|
if (! filename.empty())
|
|
|
|
{
|
|
|
|
result += " (";
|
|
|
|
}
|
2009-10-19 23:09:19 +00:00
|
|
|
if (! object.empty())
|
|
|
|
{
|
|
|
|
result += object;
|
|
|
|
if (offset > 0)
|
|
|
|
{
|
|
|
|
result += ", ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (offset > 0)
|
|
|
|
{
|
2018-02-16 23:38:05 +00:00
|
|
|
result += "offset " + QUtil::int_to_string(offset);
|
2009-10-19 23:09:19 +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())
|
|
|
|
{
|
|
|
|
result += ": ";
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|