00001 #ifndef PSTIME_EXCEPTIONS_H
00002 #define PSTIME_EXCEPTIONS_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <string>
00017 #include <cerrno>
00018 #include <boost/lexical_cast.hpp>
00019
00020
00021
00022
00023 #include "ErrSvc/Issue.h"
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 namespace PSTime {
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 class Exception : public ErrSvc::Issue {
00052 public:
00053
00054
00055 Exception ( const ErrSvc::Context& ctx,
00056 const std::string& className,
00057 const std::string& what )
00058 : ErrSvc::Issue(ctx, className+": "+what)
00059 {}
00060
00061 };
00062
00063
00064 class ErrnoException : public Exception {
00065 public:
00066
00067 ErrnoException(const ErrSvc::Context& ctx,
00068 const std::string& what)
00069 : Exception( ctx, "ErrnoException", what + ": " + strerror(errno) ) {}
00070
00071 };
00072
00073
00074 class GetTimeException : public ErrnoException {
00075 public:
00076
00077 GetTimeException(const ErrSvc::Context& ctx)
00078 : ErrnoException( ctx, "clock_gettime failed") {}
00079
00080 };
00081
00082
00083 class TimeParseException : public Exception {
00084 public:
00085
00086 TimeParseException(const ErrSvc::Context& ctx, const std::string& timestr)
00087 : Exception( ctx, "TimeParseException", "time parse failed: "+timestr) {}
00088
00089 };
00090
00091 }
00092
00093 #endif // PSTIME_EXCEPTIONS_H