[Fawkes Git] branch/vmatare/png-better-errors: created (0.5.0-3368-gfcf4c9b)

Victor Mataré matare at lih.rwth-aachen.de
Thu Nov 3 19:50:51 CET 2016


Changes have been pushed for the project "Fawkes Robotics Software Framework".

Gitweb: http://git.fawkesrobotics.org/fawkes.git
Trac:   http://trac.fawkesrobotics.org

The branch, vmatare/png-better-errors has been created
        at  fcf4c9b7397fb7b93dae3e6125ebfc569190206c (commit)

http://git.fawkesrobotics.org/fawkes.git/vmatare/png-better-errors

- *Log* ---------------------------------------------------------------
commit fcf4c9b7397fb7b93dae3e6125ebfc569190206c
Author:     Victor Mataré <matare at lih.rwth-aachen.de>
AuthorDate: Thu Nov 3 19:37:34 2016 +0100
Commit:     Victor Mataré <matare at lih.rwth-aachen.de>
CommitDate: Thu Nov 3 19:48:30 2016 +0100

    PNGReader: make file input errors helpful
    
    We don't want to leave the user guessing as to what file is involved and
    what did actually go wrong...

http://git.fawkesrobotics.org/fawkes.git/commit/fcf4c9b
http://trac.fawkesrobotics.org/changeset/fcf4c9b

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


- *Summary* -----------------------------------------------------------


- *Diffs* -------------------------------------------------------------

- *commit* fcf4c9b7397fb7b93dae3e6125ebfc569190206c - - - - - - - - - -
Author:  Victor Mataré <matare at lih.rwth-aachen.de>
Date:    Thu Nov 3 19:37:34 2016 +0100
Subject: PNGReader: make file input errors helpful

 src/libs/fvutils/readers/png.cpp |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

_Diff for modified files_:
diff --git a/src/libs/fvutils/readers/png.cpp b/src/libs/fvutils/readers/png.cpp
index 4c203f5..8808f94 100644
--- a/src/libs/fvutils/readers/png.cpp
+++ b/src/libs/fvutils/readers/png.cpp
@@ -28,6 +28,9 @@
 #include <cstdio>
 #include <cstdlib>
 #include <png.h>
+#include <cerrno>
+#include <cstring>
+#include <string>
 
 using namespace fawkes;
 
@@ -74,7 +77,7 @@ PNGReader::setup_read(const char *filename)
   d->read = false;
 
   if ((d->infile = fopen(filename, "rb")) == NULL) {
-    throw Exception("Cannot open PNG file");
+    throw Exception("Cannot open PNG file %s: %s", filename, ::strerror(errno));
   }
 
   d->png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
@@ -97,11 +100,12 @@ PNGReader::setup_read(const char *filename)
    * set up your own error handlers in the png_create_read_struct() earlier.
    */
   if (setjmp(png_jmpbuf(d->png_ptr))) {
+    std::string err(::strerror(errno));
     /* Free all of the memory associated with the png_ptr and info_ptr */
     png_destroy_read_struct(&d->png_ptr, &d->info_ptr, (png_infopp)NULL);
     fclose(d->infile);
     /* If we get here, we had a problem reading the file */
-    throw Exception("Could not read PNG file");
+    throw Exception("Could not read PNG file %s: %s", filename, err.c_str());
   }
 
   /* Set up the input control if you are using standard C streams */




-- 
Fawkes Robotics Framework                 http://www.fawkesrobotics.org


More information about the fawkes-commits mailing list