Use `TagValue::toDisplayString()` instead of handling exception

This commit is contained in:
Martchus 2022-06-19 13:32:46 +02:00
parent 7ce566729b
commit 9eeae7ae22
2 changed files with 9 additions and 6 deletions

View File

@ -199,7 +199,7 @@ if (WIDGETS_GUI OR QUICK_GUI)
endif ()
# find tagparser
find_package(tagparser${CONFIGURATION_PACKAGE_SUFFIX} 11.1.0 REQUIRED)
find_package(tagparser${CONFIGURATION_PACKAGE_SUFFIX} 11.3.0 REQUIRED)
use_tag_parser()
# enable experimental JSON export

View File

@ -263,12 +263,15 @@ static void printFieldName(std::string_view fieldName)
static void printTagValue(const TagValue &value)
{
try {
cout << value.toString(TagTextEncoding::Utf8);
} catch (const ConversionException &) {
// handle case when value can not be displayed as string
switch (value.type()) {
case TagDataType::Binary:
case TagDataType::Picture: {
const auto type = !value.mimeType().empty() ? std::string_view(value.mimeType()) : std::string_view("data");
cout << "can't display " << type << " as string (use --extract)";
std::cout << "can't display " << type << " as string (use --extract)";
break;
}
default:
std::cout << value.toDisplayString();
}
cout << '\n';
}