summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorljfa <ljfa-ag@web.de>2015-08-06 22:17:35 +0200
committerljfa-ag <ljfa-ag@web.de>2015-08-06 22:32:28 +0200
commitc596c4f7ae529e2dd9976c1963634825595c2218 (patch)
tree2d2de84388779625d28954faa44d84039c2c6d5d /src
parentd36095d36140bb6e60838d2bf379102b4b0f7bf8 (diff)
downloadProject-Tick-c596c4f7ae529e2dd9976c1963634825595c2218.tar.gz
Project-Tick-c596c4f7ae529e2dd9976c1963634825595c2218.zip
Change exception message for compound keys and tag_string
Diffstat (limited to 'src')
-rw-r--r--src/tag_compound.cpp13
-rw-r--r--src/tag_string.cpp9
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)