From 5c954a22be4825114f5ced40056cda07f6b0c106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 1 Jun 2020 11:27:04 +0200 Subject: [PATCH] imageconverter: split error handling for file opening and image loading. --- src/Magnum/Trade/imageconverter.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Magnum/Trade/imageconverter.cpp b/src/Magnum/Trade/imageconverter.cpp index 02e576f8e..8725737e3 100644 --- a/src/Magnum/Trade/imageconverter.cpp +++ b/src/Magnum/Trade/imageconverter.cpp @@ -263,10 +263,15 @@ key=true; configuration subgroups are delimited with /.)") } /* Open input file and the desired image */ - if(!importer->openFile(args.value("input")) || !(image = importer->image2D(args.value("image"), args.value("level")))) { + if(!importer->openFile(args.value("input"))) { Error() << "Cannot open file" << args.value("input"); return 3; } + + if(!(image = importer->image2D(args.value("image"), args.value("level")))) { + Error() << "Cannot import the image"; + return 4; + } } { @@ -304,6 +309,6 @@ key=true; configuration subgroups are delimited with /.)") /* Save output file */ if(!converter->exportToFile(*image, args.value("output"))) { Error() << "Cannot save file" << args.value("output"); - return 4; + return 5; } }