[Fawkes Git] branch/vmatare/png-better-errors: fvutils: make PNGReader file input errors helpful

Tim Niemueller niemueller at kbsg.rwth-aachen.de
Wed Dec 21 16:27:20 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 updated
  discards  fcf4c9b7397fb7b93dae3e6125ebfc569190206c (commit)
        to  31b65ac1e4bfb2ead38398d0876448abf9cf6822 (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (fcf4c9b7397fb7b93dae3e6125ebfc569190206c)
            \
             N -- N -- N (31b65ac1e4bfb2ead38398d0876448abf9cf6822)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

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

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- *Log* ---------------------------------------------------------------
commit 31b65ac1e4bfb2ead38398d0876448abf9cf6822
Author:     Victor Mataré <matare at lih.rwth-aachen.de>
AuthorDate: Thu Nov 3 19:37:34 2016 +0100
Commit:     Tim Niemueller <niemueller at kbsg.rwth-aachen.de>
CommitDate: Wed Dec 21 16:27:02 2016 +0100

    fvutils: make PNGReader 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/31b65ac
http://trac.fawkesrobotics.org/changeset/31b65ac

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


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


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

- *commit* 31b65ac1e4bfb2ead38398d0876448abf9cf6822 - - - - - - - - - -
Author:  Victor Mataré <matare at lih.rwth-aachen.de>
Date:    Thu Nov 3 19:37:34 2016 +0100
Subject: fvutils: make PNGReader 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