Skip to content

Commit 173ebb2

Browse files
authored
Merge pull request #2141 from Exiv2/mainErrorType
Improvements in the Error class
2 parents 5d08bb9 + fa24fb2 commit 173ebb2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1176
-1245
lines changed

README-SAMPLES.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ As Exiv2 is open source, we publish all our materials. The following programs a
6161
| _**remotetest**_ | Tester application for testing remote i/o. | [remotetest](#remotetest) |
6262
| _**stringto-test**_ | Test conversions from string to long, float and Rational types. | [stringto-test](#stringto-test) |
6363
| _**tiff-test**_ | Simple TIFF write test | [tiff-test](#tiff-test) |
64-
| _**werror-test**_ | Simple tests for the wide-string error class WError | [werror-test](#werror-test) |
6564
| _**write-test**_ | ExifData write unit tests | [write-test](#write-test) |
6665
| _**write2-test**_ | ExifData write unit tests for Exif data created from scratch | [write2-test](#write2-test) |
6766
| _**xmpparser-test**_ | Read an XMP packet from a file, parse and re-serialize it. | [xmpparser-test](#xmpparser-test)|
@@ -599,18 +598,6 @@ Simple TIFF write test
599598
[Sample](#TOC1) Programs [Test](#TOC2) Programs
600599

601600

602-
<div id="werror-test">
603-
604-
#### werror-test
605-
606-
```
607-
Usage: werror-test
608-
```
609-
610-
Simple tests for the wide-string error class WError
611-
612-
[Sample](#TOC1) Programs [Test](#TOC2) Programs
613-
614601
<div id="write-test">
615602

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

665652
Robin Mills<br>
666653
667-
Revised: 2021-09-21
654+
Revised: 2021-09-21

app/actions.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ namespace Action {
220220
}
221221
return rc;
222222
}
223-
catch(const Exiv2::AnyError& e) {
223+
catch(const Exiv2::Error& e) {
224224
std::cerr << "Exiv2 exception in print action for file "
225225
<< path << ":\n" << e << "\n";
226226
return 1;
@@ -684,7 +684,7 @@ namespace Action {
684684
}
685685
return rc;
686686
}
687-
catch(const Exiv2::AnyError& e)
687+
catch(const Exiv2::Error& e)
688688
{
689689
std::cerr << "Exiv2 exception in rename action for file " << path
690690
<< ":\n" << e << "\n";
@@ -744,7 +744,7 @@ namespace Action {
744744

745745
return rc;
746746
}
747-
catch(const Exiv2::AnyError& e)
747+
catch(const Exiv2::Error& e)
748748
{
749749
std::cerr << "Exiv2 exception in erase action for file " << path
750750
<< ":\n" << e << "\n";
@@ -854,7 +854,7 @@ namespace Action {
854854
rc = metacopy(path_, exvPath, Exiv2::ImageType::exv, false);
855855
}
856856
return rc;
857-
} catch (const Exiv2::AnyError& e) {
857+
} catch (const Exiv2::Error& e) {
858858
std::cerr << "Exiv2 exception in extract action for file " << path << ":\n" << e << "\n";
859859
return 1;
860860
}
@@ -1050,7 +1050,7 @@ namespace Action {
10501050
if (Params::instance().preserve_) ts.touch(path);
10511051
return rc;
10521052
}
1053-
catch(const Exiv2::AnyError& e)
1053+
catch(const Exiv2::Error& e)
10541054
{
10551055
std::cerr << "Exiv2 exception in insert action for file " << path
10561056
<< ":\n" << e << "\n";
@@ -1201,7 +1201,7 @@ namespace Action {
12011201

12021202
return rc;
12031203
}
1204-
catch(const Exiv2::AnyError& e)
1204+
catch(const Exiv2::Error& e)
12051205
{
12061206
std::cerr << "Exiv2 exception in modify action for file " << path
12071207
<< ":\n" << e << "\n";
@@ -1440,7 +1440,7 @@ namespace Action {
14401440
}
14411441
return rc?1:0;
14421442
}
1443-
catch(const Exiv2::AnyError& e)
1443+
catch(const Exiv2::Error& e)
14441444
{
14451445
std::cerr << "Exiv2 exception in adjust action for file " << path
14461446
<< ":\n" << e << "\n";
@@ -1576,7 +1576,7 @@ namespace Action {
15761576

15771577
return 0;
15781578
}
1579-
catch(const Exiv2::AnyError& e)
1579+
catch(const Exiv2::Error& e)
15801580
{
15811581
std::cerr << "Exiv2 exception in fixiso action for file " << path
15821582
<< ":\n" << e << "\n";
@@ -1642,7 +1642,7 @@ namespace Action {
16421642

16431643
return 0;
16441644
}
1645-
catch(const Exiv2::AnyError& e)
1645+
catch(const Exiv2::Error& e)
16461646
{
16471647
std::cerr << "Exiv2 exception in fixcom action for file " << path
16481648
<< ":\n" << e << "\n";
@@ -1886,7 +1886,7 @@ namespace {
18861886
targetImage->writeMetadata();
18871887
rc=0;
18881888
}
1889-
catch (const Exiv2::AnyError& e) {
1889+
catch (const Exiv2::Error& e) {
18901890
std::cerr << tgt <<
18911891
": " << _("Could not write metadata to file") << ": " << e << "\n";
18921892
rc=1;

app/exiv2.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ namespace {
13161316
}
13171317
}
13181318
}
1319-
catch (const Exiv2::AnyError& error) {
1319+
catch (const Exiv2::Error& error) {
13201320
std::cerr << filename << ", " << _("line") << " " << error << "\n";
13211321
return false;
13221322
}
@@ -1337,7 +1337,7 @@ namespace {
13371337
}
13381338
return true;
13391339
}
1340-
catch (const Exiv2::AnyError& error) {
1340+
catch (const Exiv2::Error& error) {
13411341
std::cerr << _("-M option") << " " << error << "\n";
13421342
return false;
13431343
}
@@ -1385,14 +1385,14 @@ namespace {
13851385
cmdLine += std::string(" ") + formatArg(__argv[i]) ;
13861386
}
13871387
#endif
1388-
throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
1388+
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
13891389
+ ": " + _("Invalid command line:") + cmdLine);
13901390
}
13911391

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

@@ -1406,25 +1406,25 @@ namespace {
14061406
defaultType = Exiv2::IptcDataSets::dataSetType(iptcKey.tag(),
14071407
iptcKey.record());
14081408
}
1409-
catch (const Exiv2::AnyError&) {}
1409+
catch (const Exiv2::Error&) {}
14101410
if (metadataId == invalidMetadataId) {
14111411
try {
14121412
Exiv2::ExifKey exifKey(key);
14131413
metadataId = exif;
14141414
defaultType = exifKey.defaultTypeId();
14151415
}
1416-
catch (const Exiv2::AnyError&) {}
1416+
catch (const Exiv2::Error&) {}
14171417
}
14181418
if (metadataId == invalidMetadataId) {
14191419
try {
14201420
Exiv2::XmpKey xmpKey(key);
14211421
metadataId = xmp;
14221422
defaultType = Exiv2::XmpProperties::propertyType(xmpKey);
14231423
}
1424-
catch (const Exiv2::AnyError&) {}
1424+
catch (const Exiv2::Error&) {}
14251425
}
14261426
if (metadataId == invalidMetadataId) {
1427-
throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
1427+
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
14281428
+ ": " + _("Invalid key") + " `" + key + "'");
14291429
}
14301430
}
@@ -1444,7 +1444,7 @@ namespace {
14441444
if ( cmdId == reg
14451445
&& ( keyEnd == std::string::npos
14461446
|| valStart == std::string::npos)) {
1447-
throw Exiv2::Error(Exiv2::kerErrorMessage, Exiv2::toString(num)
1447+
throw Exiv2::Error(Exiv2::ErrorCode::kerErrorMessage, Exiv2::toString(num)
14481448
+ ": " + _("Invalid command line") + " " );
14491449
}
14501450

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

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

include/exiv2/bmpimage.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ namespace Exiv2 {
5656
//@{
5757
void readMetadata() override;
5858

59-
/// @throws Error(kerWritingImageFormatUnsupported).
59+
/// @throws Error(ErrorCode::kerWritingImageFormatUnsupported).
6060
void writeMetadata() override;
6161

62-
/// @throws Error(kerInvalidSettingForImage)
62+
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
6363
void setExifData(const ExifData& exifData) override;
6464

65-
/// @throws Error(kerInvalidSettingForImage)
65+
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
6666
void setIptcData(const IptcData& iptcData) override;
6767

68-
/// @throws Error(kerInvalidSettingForImage)
68+
/// @throws Error(ErrorCode::kerInvalidSettingForImage)
6969
void setComment(std::string_view comment) override;
7070
//@}
7171

include/exiv2/cr2image.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ namespace Exiv2 {
6060
void printStructure(std::ostream& out, PrintStructureOption option, int depth) override;
6161
/*!
6262
@brief Not supported. CR2 format does not contain a comment.
63-
Calling this function will throw an Error(kerInvalidSettingForImage).
63+
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
6464
*/
6565
void setComment(std::string_view comment) override;
6666
//@}

include/exiv2/crwimage.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace Exiv2 {
6161
void writeMetadata() override;
6262
/*!
6363
@brief Not supported. CRW format does not contain IPTC metadata.
64-
Calling this function will throw an Error(kerInvalidSettingForImage).
64+
Calling this function will throw an Error(ErrorCode::kerInvalidSettingForImage).
6565
*/
6666
void setIptcData(const IptcData& iptcData) override;
6767
//@}

include/exiv2/epsimage.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace Exiv2
6161
void writeMetadata() override;
6262
/*!
6363
@brief Not supported.
64-
Calling this function will throw an instance of Error(kerInvalidSettingForImage).
64+
Calling this function will throw an instance of Error(ErrorCode::kerInvalidSettingForImage).
6565
*/
6666
void setComment(std::string_view comment) override;
6767
//@}

0 commit comments

Comments
 (0)