]> git.tdb.fi Git - libs/core.git/commitdiff
Add LogicError exception class
authorMikko Rasa <tdb@tdb.fi>
Mon, 21 Dec 2009 07:27:10 +0000 (07:27 +0000)
committerMikko Rasa <tdb@tdb.fi>
Mon, 21 Dec 2009 07:27:10 +0000 (07:27 +0000)
Throw InvalidState in DateTime::get_timestamp for out-of-range values

source/core/except.h
source/time/datetime.cpp

index bf7c526c378695d353098ef694311ff8231226cc..6d34d4bd48d9309042c8f7fe6e6d9eb401053e2c 100644 (file)
@@ -97,6 +97,15 @@ private:
        static std::string build_what(const std::string &, int);
 };
 
+/**
+Thrown when "impossible" things happen.
+*/
+class LogicError: public Exception
+{
+public:
+       LogicError(const std::string &w_): Exception(w_) { }
+};
+
 template<typename E>
 void throw_at(E e, const std::string &a)
 { e.at(a); throw e; }
index 2c6fceaad135b773b298cd9cbdcac00c4cfe945e..86238863282340996339071236f51b4a212e193f 100644 (file)
@@ -203,7 +203,7 @@ int DateTime::cmp(const DateTime &dt) const
 TimeStamp DateTime::get_timestamp() const
 {
        if(year<-289701 || year>293641)
-               throw Exception("DateTime is not representable as a TimeStamp");
+               throw InvalidState("DateTime is not representable as a TimeStamp");
 
        RawTime raw=(((hour*60LL)+minute)*60+second)*1000000+usec;
        int days=(year-1970)*365;