Skip to content

Commit

Permalink
Merge pull request #2141 from Exiv2/mainErrorType
Browse files Browse the repository at this point in the history
Improvements in the Error class
  • Loading branch information
piponazo authored Mar 14, 2022
2 parents 5d08bb9 + fa24fb2 commit 173ebb2
Show file tree
Hide file tree
Showing 96 changed files with 1,176 additions and 1,245 deletions.
15 changes: 1 addition & 14 deletions README-SAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ As Exiv2 is open source, we publish all our materials. The following programs a
| _**remotetest**_ | Tester application for testing remote i/o. | [remotetest](#remotetest) |
| _**stringto-test**_ | Test conversions from string to long, float and Rational types. | [stringto-test](#stringto-test) |
| _**tiff-test**_ | Simple TIFF write test | [tiff-test](#tiff-test) |
| _**werror-test**_ | Simple tests for the wide-string error class WError | [werror-test](#werror-test) |
| _**write-test**_ | ExifData write unit tests | [write-test](#write-test) |
| _**write2-test**_ | ExifData write unit tests for Exif data created from scratch | [write2-test](#write2-test) |
| _**xmpparser-test**_ | Read an XMP packet from a file, parse and re-serialize it. | [xmpparser-test](#xmpparser-test)|
Expand Down Expand Up @@ -599,18 +598,6 @@ Simple TIFF write test
[Sample](#TOC1) Programs [Test](#TOC2) Programs


<div id="werror-test">

#### werror-test

```
Usage: werror-test
```

Simple tests for the wide-string error class WError

[Sample](#TOC1) Programs [Test](#TOC2) Programs

<div id="write-test">

#### write-test
Expand Down Expand Up @@ -664,4 +651,4 @@ Read an XMP packet from a file, parse and re-serialize it.

Robin Mills<br>
[email protected]<br>
Revised: 2021-09-21
Revised: 2021-09-21
20 changes: 10 additions & 10 deletions app/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ namespace Action {
}
return rc;
}
catch(const Exiv2::AnyError& e) {
catch(const Exiv2::Error& e) {
std::cerr << "Exiv2 exception in print action for file "
<< path << ":\n" << e << "\n";
return 1;
Expand Down Expand Up @@ -684,7 +684,7 @@ namespace Action {
}
return rc;
}
catch(const Exiv2::AnyError& e)
catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in rename action for file " << path
<< ":\n" << e << "\n";
Expand Down Expand Up @@ -744,7 +744,7 @@ namespace Action {

return rc;
}
catch(const Exiv2::AnyError& e)
catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in erase action for file " << path
<< ":\n" << e << "\n";
Expand Down Expand Up @@ -854,7 +854,7 @@ namespace Action {
rc = metacopy(path_, exvPath, Exiv2::ImageType::exv, false);
}
return rc;
} catch (const Exiv2::AnyError& e) {
} catch (const Exiv2::Error& e) {
std::cerr << "Exiv2 exception in extract action for file " << path << ":\n" << e << "\n";
return 1;
}
Expand Down Expand Up @@ -1050,7 +1050,7 @@ namespace Action {
if (Params::instance().preserve_) ts.touch(path);
return rc;
}
catch(const Exiv2::AnyError& e)
catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in insert action for file " << path
<< ":\n" << e << "\n";
Expand Down Expand Up @@ -1201,7 +1201,7 @@ namespace Action {

return rc;
}
catch(const Exiv2::AnyError& e)
catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in modify action for file " << path
<< ":\n" << e << "\n";
Expand Down Expand Up @@ -1440,7 +1440,7 @@ namespace Action {
}
return rc?1:0;
}
catch(const Exiv2::AnyError& e)
catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in adjust action for file " << path
<< ":\n" << e << "\n";
Expand Down Expand Up @@ -1576,7 +1576,7 @@ namespace Action {

return 0;
}
catch(const Exiv2::AnyError& e)
catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in fixiso action for file " << path
<< ":\n" << e << "\n";
Expand Down Expand Up @@ -1642,7 +1642,7 @@ namespace Action {

return 0;
}
catch(const Exiv2::AnyError& e)
catch(const Exiv2::Error& e)
{
std::cerr << "Exiv2 exception in fixcom action for file " << path
<< ":\n" << e << "\n";
Expand Down Expand Up @@ -1886,7 +1886,7 @@ namespace {
targetImage->writeMetadata();
rc=0;
}
catch (const Exiv2::AnyError& e) {
catch (const Exiv2::Error& e) {
std::cerr << tgt <<
": " << _("Could not write metadata to file") << ": " << e << "\n";
rc=1;
Expand Down
22 changes: 11 additions & 11 deletions app/exiv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ namespace {
}
}
}
catch (const Exiv2::AnyError& error) {
catch (const Exiv2::Error& error) {
std::cerr << filename << ", " << _("line") << " " << error << "\n";
return false;
}
Expand All @@ -1337,7 +1337,7 @@ namespace {
}
return true;
}
catch (const Exiv2::AnyError& error) {
catch (const Exiv2::Error& error) {
std::cerr << _("-M option") << " " << error << "\n";
return false;
}
Expand Down Expand Up @@ -1385,14 +1385,14 @@ namespace {
cmdLine += std::string(" ") + formatArg(__argv[i]) ;
}
#endif
throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
+ ": " + _("Invalid command line:") + cmdLine);
}

std::string cmd(line.substr(cmdStart, cmdEnd-cmdStart));
CmdId cmdId = commandId(cmd);
if (cmdId == invalidCmdId) {
throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
+ ": " + _("Invalid command") + " `" + cmd + "'");
}

Expand All @@ -1406,25 +1406,25 @@ namespace {
defaultType = Exiv2::IptcDataSets::dataSetType(iptcKey.tag(),
iptcKey.record());
}
catch (const Exiv2::AnyError&) {}
catch (const Exiv2::Error&) {}
if (metadataId == invalidMetadataId) {
try {
Exiv2::ExifKey exifKey(key);
metadataId = exif;
defaultType = exifKey.defaultTypeId();
}
catch (const Exiv2::AnyError&) {}
catch (const Exiv2::Error&) {}
}
if (metadataId == invalidMetadataId) {
try {
Exiv2::XmpKey xmpKey(key);
metadataId = xmp;
defaultType = Exiv2::XmpProperties::propertyType(xmpKey);
}
catch (const Exiv2::AnyError&) {}
catch (const Exiv2::Error&) {}
}
if (metadataId == invalidMetadataId) {
throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
+ ": " + _("Invalid key") + " `" + key + "'");
}
}
Expand All @@ -1444,7 +1444,7 @@ namespace {
if ( cmdId == reg
&& ( keyEnd == std::string::npos
|| valStart == std::string::npos)) {
throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
+ ": " + _("Invalid command line") + " " );
}

Expand All @@ -1456,7 +1456,7 @@ namespace {
if (tmpType != Exiv2::invalidTypeId) {
valStart = line.find_first_not_of(delim, typeEnd+1);
if (valStart == std::string::npos) {
throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
+ ": " + _("Invalid command line") + " " );
}
type = tmpType;
Expand All @@ -1483,7 +1483,7 @@ namespace {

if (cmdId == reg) {
if (value.empty()) {
throw Exiv2::Error(Exiv2::kerErrorMessage,
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage,
Exiv2::toString(num) + ": " + _("Empty value for key") + + " `" + key + "'");
}

Expand Down
8 changes: 4 additions & 4 deletions include/exiv2/bmpimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ namespace Exiv2 {
//@{
void readMetadata() override;

/// @throws Error(kerWritingImageFormatUnsupported).
/// @throws Error(ErrorCode::kerWritingImageFormatUnsupported).
void writeMetadata() override;

/// @throws Error(kerInvalidSettingForImage)
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
void setExifData(const ExifData& exifData) override;

/// @throws Error(kerInvalidSettingForImage)
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
void setIptcData(const IptcData& iptcData) override;

/// @throws Error(kerInvalidSettingForImage)
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
void setComment(std::string_view comment) override;
//@}

Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/cr2image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace Exiv2 {
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
/*!
@brief Not supported. CR2 format does not contain a comment.
Calling this function will throw an Error(kerInvalidSettingForImage).
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/crwimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace Exiv2 {
void writeMetadata() override;
/*!
@brief Not supported. CRW format does not contain IPTC metadata.
Calling this function will throw an Error(kerInvalidSettingForImage).
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
*/
void setIptcData(const IptcData& iptcData) override;
//@}
Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/epsimage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace Exiv2
void writeMetadata() override;
/*!
@brief Not supported.
Calling this function will throw an instance of Error(kerInvalidSettingForImage).
Calling this function will throw an instance of Error(ErrorCode::kerInvalidSettingForImage).
*/
void setComment(std::string_view comment) override;
//@}
Expand Down
Loading

0 comments on commit 173ebb2

Please sign in to comment.