|
|
4a042c |
diff --git a/src/exiv2.cpp b/src/exiv2.cpp
|
|
|
4a042c |
index d6a45e1..dbd2834 100644
|
|
|
4a042c |
--- a/src/exiv2.cpp
|
|
|
4a042c |
+++ b/src/exiv2.cpp
|
|
|
4a042c |
@@ -150,31 +150,35 @@ int main(int argc, char* const argv[])
|
|
|
4a042c |
return 0;
|
|
|
4a042c |
}
|
|
|
4a042c |
|
|
|
4a042c |
- // Create the required action class
|
|
|
4a042c |
- Action::TaskFactory& taskFactory = Action::TaskFactory::instance();
|
|
|
4a042c |
- Action::Task::AutoPtr task
|
|
|
4a042c |
- = taskFactory.create(Action::TaskType(params.action_));
|
|
|
4a042c |
- assert(task.get());
|
|
|
4a042c |
-
|
|
|
4a042c |
- // Process all files
|
|
|
4a042c |
int rc = 0;
|
|
|
4a042c |
- int n = 1;
|
|
|
4a042c |
- int s = static_cast<int>(params.files_.size());
|
|
|
4a042c |
- int w = s > 9 ? s > 99 ? 3 : 2 : 1;
|
|
|
4a042c |
- for (Params::Files::const_iterator i = params.files_.begin();
|
|
|
4a042c |
- i != params.files_.end(); ++i) {
|
|
|
4a042c |
- if (params.verbose_) {
|
|
|
4a042c |
- std::cout << _("File") << " " << std::setw(w) << std::right << n++ << "/" << s << ": "
|
|
|
4a042c |
- << *i << std::endl;
|
|
|
4a042c |
+ try {
|
|
|
4a042c |
+ // Create the required action class
|
|
|
4a042c |
+ Action::TaskFactory& taskFactory = Action::TaskFactory::instance();
|
|
|
4a042c |
+ Action::Task::AutoPtr task = taskFactory.create(Action::TaskType(params.action_));
|
|
|
4a042c |
+ assert(task.get());
|
|
|
4a042c |
+
|
|
|
4a042c |
+ // Process all files
|
|
|
4a042c |
+ int n = 1;
|
|
|
4a042c |
+ int s = static_cast<int>(params.files_.size());
|
|
|
4a042c |
+ int w = s > 9 ? s > 99 ? 3 : 2 : 1;
|
|
|
4a042c |
+ for (Params::Files::const_iterator i = params.files_.begin(); i != params.files_.end(); ++i) {
|
|
|
4a042c |
+ if (params.verbose_) {
|
|
|
4a042c |
+ std::cout << _("File") << " " << std::setw(w) << std::right << n++ << "/" << s << ": " << *i
|
|
|
4a042c |
+ << std::endl;
|
|
|
4a042c |
+ }
|
|
|
4a042c |
+ int ret = task->run(*i);
|
|
|
4a042c |
+ if (rc == 0)
|
|
|
4a042c |
+ rc = ret;
|
|
|
4a042c |
}
|
|
|
4a042c |
- int ret = task->run(*i);
|
|
|
4a042c |
- if (rc == 0) rc = ret;
|
|
|
4a042c |
- }
|
|
|
4a042c |
|
|
|
4a042c |
- taskFactory.cleanup();
|
|
|
4a042c |
- params.cleanup();
|
|
|
4a042c |
- Exiv2::XmpParser::terminate();
|
|
|
4a042c |
+ taskFactory.cleanup();
|
|
|
4a042c |
+ params.cleanup();
|
|
|
4a042c |
+ Exiv2::XmpParser::terminate();
|
|
|
4a042c |
|
|
|
4a042c |
+ } catch (const std::exception& exc) {
|
|
|
4a042c |
+ std::cerr << "Uncaught exception: " << exc.what() << std::endl;
|
|
|
4a042c |
+ rc = 1;
|
|
|
4a042c |
+ }
|
|
|
4a042c |
// Return a positive one byte code for better consistency across platforms
|
|
|
4a042c |
return static_cast<unsigned int>(rc) % 256;
|
|
|
4a042c |
} // main
|