From c596c4f7ae529e2dd9976c1963634825595c2218 Mon Sep 17 00:00:00 2001 From: ljfa Date: Thu, 6 Aug 2015 22:17:35 +0200 Subject: Change exception message for compound keys and tag_string --- src/tag_compound.cpp | 13 ++++++++++++- src/tag_string.cpp | 9 ++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'src') 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 +#include 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) -- cgit 0.0.5-2-1-g0f52