changeset 1528:6fdb447d87b7

improved Exiv2 error reporting: - use correct charset - respect --debug
author nadvornik
date Wed, 08 Apr 2009 19:32:30 +0000
parents 12b0eeb5d528
children 1bcf1f1d5af5
files src/exiv2.cc
diffstat 1 files changed, 28 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/exiv2.cc	Mon Apr 06 23:59:54 2009 +0000
+++ b/src/exiv2.cc	Wed Apr 08 19:32:30 2009 +0000
@@ -101,6 +101,13 @@
 	{NULL, NULL, NULL}
 	};
 
+static void debug_exception(Exiv2::AnyError& e)
+{
+	gchar *str = g_locale_from_utf8(e.what(), -1, NULL, NULL, NULL);
+	DEBUG_1("Exiv2: %s", str);
+	g_free(str);
+}
+
 struct _ExifData
 {
 	Exiv2::ExifData::const_iterator exifIter; /* for exif_get_next_item */
@@ -414,7 +421,7 @@
 		return new _ExifDataProcessed(path, sidecar_path, modified_xmp);
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return NULL;
 	}
 	
@@ -427,7 +434,7 @@
 		return TRUE;
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return FALSE;
 	}
 }
@@ -439,7 +446,7 @@
 		return TRUE;
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return FALSE;
 	}
 	
@@ -488,7 +495,7 @@
 		return (ExifItem *)item;
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return NULL;
 	}
 }
@@ -525,7 +532,7 @@
 		return (ExifItem *)item;
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return NULL;
 	}
 }
@@ -563,7 +570,7 @@
 			
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return NULL;
 	}
 }
@@ -594,7 +601,7 @@
 		return NULL;
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return NULL;
 	}
 }
@@ -606,7 +613,7 @@
 		return g_strdup(((Exiv2::Metadatum *)item)->key().c_str());
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return NULL;
 	}
 }
@@ -618,7 +625,7 @@
 		return ((Exiv2::Metadatum *)item)->tag();
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return 0;
 	}
 }
@@ -630,7 +637,7 @@
 		return ((Exiv2::Metadatum *)item)->count();
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return 0;
 	}
 }
@@ -647,7 +654,7 @@
 		return data;
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return NULL;
 	}
 }
@@ -659,7 +666,7 @@
 		return utf8_validate_or_convert(((Exiv2::Metadatum *)item)->tagLabel().c_str());
 	}
 	catch (std::exception& e) {
-//		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+//		debug_exception(e);
 		return NULL;
 	}
 }
@@ -706,7 +713,7 @@
 		return format_id_trans_tbl[id];
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return EXIF_FORMAT_UNKNOWN;
 	}
 }
@@ -718,7 +725,7 @@
 		return ((Exiv2::Metadatum *)item)->typeName();
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return NULL;
 	}
 }
@@ -788,7 +795,7 @@
 		return 1;
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return 0;
 	}
 }
@@ -806,7 +813,7 @@
 		return &ret;
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return NULL;
 	}
 }
@@ -830,7 +837,7 @@
 #endif
 			}
 			catch (Exiv2::AnyError& e) {
-				std::cout << "Caught Exiv2 exception '" << e << "'\n";
+				debug_exception(e);
 				return NULL;
 			}
 		}
@@ -911,7 +918,7 @@
 		return 1;
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return 0;
 	}
 }
@@ -1049,7 +1056,7 @@
 		}
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 	}
 	return list;
 }
@@ -1160,7 +1167,7 @@
 		return NULL;
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 		return NULL;
 	}
 }
@@ -1258,7 +1265,7 @@
 		
 	}
 	catch (Exiv2::AnyError& e) {
-		std::cout << "Caught Exiv2 exception '" << e << "'\n";
+		debug_exception(e);
 	}
 	return NULL;