aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFExc.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2009-10-20 01:09:19 +0200
committerJay Berkenbilt <ejb@ql.org>2009-10-20 01:09:19 +0200
commit3f8c4c273649c857f5a607dcbb422729fce3a166 (patch)
tree9a71fbfc838cf876f7982f7213ad994c92c0a3fc /libqpdf/QPDFExc.cc
parentb67a3c15e768ed88ea3cdf7525c1ddc649aec2fe (diff)
downloadqpdf-3f8c4c273649c857f5a607dcbb422729fce3a166.tar.zst
categorize all error messages and include object information if available
git-svn-id: svn+q:///qpdf/trunk@829 71b93d88-0707-0410-a8cf-f5a4172ac649
Diffstat (limited to 'libqpdf/QPDFExc.cc')
-rw-r--r--libqpdf/QPDFExc.cc52
1 files changed, 45 insertions, 7 deletions
diff --git a/libqpdf/QPDFExc.cc b/libqpdf/QPDFExc.cc
index 006a96ac..614990a9 100644
--- a/libqpdf/QPDFExc.cc
+++ b/libqpdf/QPDFExc.cc
@@ -1,18 +1,56 @@
#include <qpdf/QPDFExc.hh>
#include <qpdf/QUtil.hh>
-QPDFExc::QPDFExc(std::string const& message) :
- std::runtime_error(message)
+QPDFExc::QPDFExc(qpdf_error_code_e error_code,
+ std::string const& filename,
+ std::string const& object,
+ off_t offset,
+ std::string const& message) :
+ std::runtime_error(createWhat(filename, object, offset, message)),
+ error_code(error_code),
+ filename(filename),
+ object(object),
+ offset(offset),
+ message(message)
{
}
-QPDFExc::QPDFExc(std::string const& filename, int offset,
- std::string const& message) :
- std::runtime_error(filename + ": offset " + QUtil::int_to_string(offset) +
- ": " + message)
+QPDFExc::~QPDFExc() throw ()
{
}
-QPDFExc::~QPDFExc() throw ()
+std::string
+QPDFExc::createWhat(std::string const& filename,
+ std::string const& object,
+ off_t offset,
+ std::string const& message)
{
+ std::string result;
+ if (! filename.empty())
+ {
+ result += filename;
+ }
+ if (! (object.empty() && offset == 0))
+ {
+ result += " (";
+ if (! object.empty())
+ {
+ result += object;
+ if (offset > 0)
+ {
+ result += ", ";
+ }
+ }
+ if (offset > 0)
+ {
+ result += "file position " + QUtil::int_to_string(offset);
+ }
+ result += ")";
+ }
+ if (! result.empty())
+ {
+ result += ": ";
+ }
+ result += message;
+ return result;
}