00001 #include "Exception.hpp"
00002 #include <sstream>
00003
00004 namespace aitools {
00005 namespace invertedindex {
00006
00007 void
00008 Exception::throw_invalid_argument(const std::string& msg, const bfs::path& path)
00009 throw (std::invalid_argument)
00010 {
00011 std::ostringstream oss;
00012 oss << msg << " [ path = " << path.string() << " ]";
00013 throw std::invalid_argument(oss.str());
00014 }
00015
00016 void
00017 Exception::throw_invalid_argument(const std::string& msg)
00018 throw (std::invalid_argument)
00019 {
00020 throw std::invalid_argument(msg);
00021 }
00022
00023 void
00024 Exception::throw_out_of_range(const std::string& msg, unsigned value)
00025 throw (std::out_of_range)
00026 {
00027 std::ostringstream oss;
00028 oss << msg << " [ value = " << value << " ]";
00029 throw std::out_of_range(oss.str());
00030 }
00031
00032 void
00033 Exception::throw_out_of_range(const std::string& msg, unsigned index,
00034 unsigned size) throw (std::out_of_range)
00035 {
00036 std::ostringstream oss;
00037 oss << msg << " [ index = " << index << " , size = " << size << " ]";
00038 throw std::out_of_range(oss.str());
00039 }
00040
00041 void
00042 Exception::throw_out_of_range(const std::string& msg, unsigned off,
00043 unsigned num, unsigned size) throw (std::out_of_range)
00044 {
00045 std::ostringstream oss;
00046 oss << msg << " [ off = " << off << " , num = "
00047 << num << " , size = " << size << " ]";
00048 throw std::out_of_range(oss.str());
00049 }
00050
00051 void
00052 Exception::throw_length_error(const std::string& msg, unsigned value)
00053 throw (std::length_error)
00054 {
00055 std::ostringstream oss;
00056 oss << msg << " [ value = " << value << " ]";
00057 throw std::length_error(oss.str());
00058 }
00059
00060 void
00061 Exception::throw_logic_error(const std::string& msg)
00062 throw (std::logic_error)
00063 {
00064 throw std::logic_error(msg);
00065 }
00066
00067 void
00068 Exception::throw_domain_error(const std::string& msg)
00069 throw (std::domain_error)
00070 {
00071 throw std::domain_error(msg);
00072 }
00073
00074 void
00075 Exception::throw_runtime_error(const std::string& msg)
00076 throw (std::runtime_error)
00077 {
00078 throw std::runtime_error(msg);
00079 }
00080
00081 void
00082 Exception::throw_overflow_error(const std::string& msg)
00083 throw (std::overflow_error)
00084 {
00085 throw std::overflow_error(msg);
00086 }
00087
00088 void
00089 Exception::throw_underflow_error(const std::string& msg)
00090 throw (std::underflow_error)
00091 {
00092 throw std::underflow_error(msg);
00093 }
00094
00095 }
00096 }