reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 6520c5739a4927719885167797c3063929df4ebd
parent a24a7478d2ab00315f78dcfc0e136bf6c8b34ff5
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Mon,  1 Feb 2016 20:23:59 -0500

enhence error reporting when parsing index files

Diffstat:
Msrc/index.cpp | 10++++++----
Mtest/index.cpp | 4++--
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/index.cpp b/src/index.cpp @@ -21,6 +21,7 @@ #include "errors.hpp" #include "path.hpp" +#include <cerrno> #include <WDL/tinyxml/tinyxml.h> using namespace std; @@ -47,13 +48,14 @@ RemoteIndex *RemoteIndex::load(const string &name) FILE *file = OpenFile(pathFor(name).join().c_str()); - const bool success = doc.LoadFile(file); + if(!file) + throw reapack_error(strerror(errno)); - if(file) - fclose(file); + const bool success = doc.LoadFile(file); + fclose(file); if(!success) - throw reapack_error("failed to read index"); + throw reapack_error(doc.ErrorDesc()); TiXmlHandle docHandle(&doc); TiXmlElement *root = doc.RootElement(); diff --git a/test/index.cpp b/test/index.cpp @@ -21,7 +21,7 @@ TEST_CASE("file not found", M) { FAIL(); } catch(const reapack_error &e) { - REQUIRE(string(e.what()) == "failed to read index"); + REQUIRE(string(e.what()) == "No such file or directory"); } } @@ -34,7 +34,7 @@ TEST_CASE("broken", M) { FAIL(); } catch(const reapack_error &e) { - REQUIRE(string(e.what()) == "failed to read index"); + REQUIRE(string(e.what()) == "Error reading end tag."); } }