From fd32c7c7d05bc7e823d7e129d16193be4635b0c7 Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Sat, 5 Sep 2015 13:00:31 +0200 Subject: Change some exception types thrown by tag_list --- src/tag_list.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/tag_list.cpp b/src/tag_list.cpp index a1a708a6a6..039bd9b77a 100644 --- a/src/tag_list.cpp +++ b/src/tag_list.cpp @@ -48,7 +48,7 @@ tag_list::tag_list(std::initializer_list init) for(const value& val: init) { if(!val || val.get_type() != el_type_) - throw std::bad_cast(); + throw std::invalid_argument("The values are not all the same type"); } tags.assign(init.begin(), init.end()); } @@ -67,18 +67,18 @@ const value& tag_list::at(size_t i) const void tag_list::set(size_t i, value&& val) { if(val.get_type() != el_type_) - throw std::bad_cast(); + throw std::invalid_argument("The tag type does not match the list's content type"); tags.at(i) = std::move(val); } void tag_list::push_back(value_initializer&& val) { if(!val) //don't allow null values - throw std::bad_cast(); + throw std::invalid_argument("The value must not be null"); if(el_type_ == tag_type::Null) //set content type if undetermined el_type_ = val.get_type(); else if(el_type_ != val.get_type()) - throw std::bad_cast(); + throw std::invalid_argument("The tag type does not match the list's content type"); tags.push_back(std::move(val)); } @@ -131,7 +131,7 @@ void tag_list::write_payload(io::stream_writer& writer) const if(val.get_type() != el_type_) { writer.get_ostr().setstate(std::ios::failbit); - throw std::bad_cast(); + throw std::logic_error("The tags in the list do not all match the content type"); } writer.write_payload(val); } -- cgit 0.0.5-2-1-g0f52