From 04ae6c2c4c8184927b3a8fed8730bfad706ae9fb Mon Sep 17 00:00:00 2001 From: Jim Easterbrook Date: Mon, 14 Mar 2022 12:17:54 +0000 Subject: [PATCH] Add key name to "Value not set" error message (#2149) The error typically occurs when writeMetadata() is called. It's easier to find the problem if you know which datum hasn't had a value set. --- src/error.cpp | 2 +- src/exif.cpp | 2 +- src/iptc.cpp | 2 +- src/xmp.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/error.cpp b/src/error.cpp index 5873e42a..38b503f7 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -23,7 +23,7 @@ namespace N_("Invalid record name '%1'"), // kerInvalidRecord %1=record name N_("Invalid key '%1'"), // kerInvalidKey %1=key N_("Invalid tag name or ifdId `%1', ifdId %2"), // kerInvalidTag %1=tag name, %2=ifdId - N_("Value not set"), // kerValueNotSet + N_("%1 value not set"), // kerValueNotSet %1=key name N_("%1: Failed to open the data source: %2"), // kerDataSourceOpenFailed %1=path, %2=strerror N_("%1: Failed to open file (%2): %3"), // kerFileOpenFailed %1=path, %2=mode, %3=strerror N_("%1: The file contains data of an unknown image type"), // kerFileContainsUnknownImageType %1=path diff --git a/src/exif.cpp b/src/exif.cpp index a5691e5a..475f2ef2 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -205,7 +205,7 @@ namespace Exiv2 { const Value& Exifdatum::value() const { if (!value_) - throw Error(ErrorCode::kerValueNotSet); + throw Error(ErrorCode::kerValueNotSet, key()); return *value_; } diff --git a/src/iptc.cpp b/src/iptc.cpp index 953da4e1..cba23ee2 100644 --- a/src/iptc.cpp +++ b/src/iptc.cpp @@ -131,7 +131,7 @@ namespace Exiv2 { const Value& Iptcdatum::value() const { if (!value_) - throw Error(ErrorCode::kerValueNotSet); + throw Error(ErrorCode::kerValueNotSet, key()); return *value_; } diff --git a/src/xmp.cpp b/src/xmp.cpp index f8f9a66c..8db5007b 100644 --- a/src/xmp.cpp +++ b/src/xmp.cpp @@ -369,7 +369,7 @@ namespace Exiv2 { const Value& Xmpdatum::value() const { if (!p_->value_) - throw Error(ErrorCode::kerValueNotSet); + throw Error(ErrorCode::kerValueNotSet, key()); return *p_->value_; }