From 3340dbe9761ef35d580d77a73e17d204579624f1 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 10 Dec 2021 09:34:42 -0500 Subject: Use a specific error code for type warnings and clarify docs --- libqpdf/QPDFObjectHandle.cc | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index af862bd4..1a8e3223 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -3048,23 +3048,17 @@ void QPDFObjectHandle::typeWarning(char const* expected_type, std::string const& warning) { - QPDF* context = 0; + QPDF* context = nullptr; std::string description; dereference(); - if (this->obj->getDescription(context, description)) - { - warn(context, - QPDFExc( - qpdf_e_damaged_pdf, + this->obj->getDescription(context, description); + // Null context handled by warn + warn(context, + QPDFExc(qpdf_e_object, "", description, 0, std::string("operation for ") + expected_type + " attempted on object of type " + getTypeName() + ": " + warning)); - } - else - { - assertType(expected_type, false); - } } void @@ -3091,7 +3085,12 @@ QPDFObjectHandle::warnIfPossible(std::string const& warning, void QPDFObjectHandle::objectWarning(std::string const& warning) { - warnIfPossible(warning, true); + QPDF* context = nullptr; + std::string description; + dereference(); + this->obj->getDescription(context, description); + // Null context handled by warn + warn(context, QPDFExc(qpdf_e_object, "", description, 0, warning)); } void -- cgit v1.2.3-54-g00ecf