X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fstlplus%2Fpersistence%2Fpersistent_exceptions.cpp;fp=src%2Fstlplus%2Fpersistence%2Fpersistent_exceptions.cpp;h=d2338261c64a62938873ffbe78f61cbf113cd299;hb=6b0a0d0efafe34d48ab344fca3b479553bd4e62c;hp=0000000000000000000000000000000000000000;hpb=85783316365181491a3e3c0c63659972477cebba;p=chaz%2Fyoink diff --git a/src/stlplus/persistence/persistent_exceptions.cpp b/src/stlplus/persistence/persistent_exceptions.cpp new file mode 100644 index 0000000..d233826 --- /dev/null +++ b/src/stlplus/persistence/persistent_exceptions.cpp @@ -0,0 +1,64 @@ +//////////////////////////////////////////////////////////////////////////////// + +// Author: Andy Rushton +// Copyright: (c) Southampton University 1999-2004 +// (c) Andy Rushton 2004-2009 +// License: BSD License, see ../docs/license.html + +//////////////////////////////////////////////////////////////////////////////// + +#include "persistent_exceptions.hpp" +#include + +//////////////////////////////////////////////////////////////////////////////// + +static std::string to_string(int number) +{ + // use sprintf in a very controlled way that cannot overrun + char* buffer = new char[50]; + sprintf(buffer, "%i", number); + std::string result = buffer; + delete buffer; + return result; +} + +//////////////////////////////////////////////////////////////////////////////// +// exceptions + +stlplus::persistent_illegal_type::persistent_illegal_type(const std::string& type) throw() : + std::logic_error(std::string("illegal type: ") + type) +{ +} + +stlplus::persistent_illegal_type::persistent_illegal_type(unsigned key) throw() : + std::logic_error(std::string("illegal key: ") + to_string((int)key)) +{ +} + +stlplus::persistent_illegal_type::~persistent_illegal_type(void) throw() +{ +} + +//////////////////////////////////////////////////////////////////////////////// + +stlplus::persistent_dump_failed::persistent_dump_failed(const std::string& message) throw() : + std::runtime_error(std::string("dump failed: ") + message) +{ +} + +stlplus::persistent_dump_failed::~persistent_dump_failed(void) throw() +{ +} + +//////////////////////////////////////////////////////////////////////////////// + +stlplus::persistent_restore_failed::persistent_restore_failed(const std::string& message) throw() : + std::runtime_error(std::string("restore failed: ") + message) +{ +} + +stlplus::persistent_restore_failed::~persistent_restore_failed(void) throw() +{ +} + +////////////////////////////////////////////////////////////////////////////////