diff options
| author | ljfa <ljfa-ag@web.de> | 2015-08-06 22:17:35 +0200 |
|---|---|---|
| committer | ljfa-ag <ljfa-ag@web.de> | 2015-08-06 22:32:28 +0200 |
| commit | c596c4f7ae529e2dd9976c1963634825595c2218 (patch) | |
| tree | 2d2de84388779625d28954faa44d84039c2c6d5d | |
| parent | d36095d36140bb6e60838d2bf379102b4b0f7bf8 (diff) | |
| download | Project-Tick-c596c4f7ae529e2dd9976c1963634825595c2218.tar.gz Project-Tick-c596c4f7ae529e2dd9976c1963634825595c2218.zip | |
Change exception message for compound keys and tag_string
| -rw-r--r-- | src/tag_compound.cpp | 13 | ||||
| -rw-r--r-- | src/tag_string.cpp | 9 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/tag_compound.cpp b/src/tag_compound.cpp index 3821ba8f98..3581dd149b 100644 --- a/src/tag_compound.cpp +++ b/src/tag_compound.cpp @@ -20,6 +20,7 @@ #include "tag_compound.h" #include "io/stream_reader.h" #include <istream> +#include <sstream> namespace nbt { @@ -103,7 +104,17 @@ void tag_compound::read_payload(io::stream_reader& reader) tag_type tt; while((tt = reader.read_type(true)) != tag_type::End) { - std::string key = reader.read_string(); + std::string key; + try + { + key = reader.read_string(); + } + catch(io::input_error& ex) + { + std::ostringstream str; + str << "Error reading key of tag_" << tt; + throw io::input_error(str.str()); + } auto tptr = reader.read_payload(tt); tags.emplace(std::move(key), value(std::move(tptr))); } diff --git a/src/tag_string.cpp b/src/tag_string.cpp index 4671339561..83cb815c52 100644 --- a/src/tag_string.cpp +++ b/src/tag_string.cpp @@ -80,7 +80,14 @@ void tag_string::set(std::string&& str) void tag_string::read_payload(io::stream_reader& reader) { - value = reader.read_string(); + try + { + value = reader.read_string(); + } + catch(io::input_error& ex) + { + throw io::input_error("Error reading tag_string"); + } } bool operator==(const tag_string& lhs, const tag_string& rhs) |
