PSTime/include/Exceptions.h

Go to the documentation of this file.
00001 #ifndef PSTIME_EXCEPTIONS_H
00002 #define PSTIME_EXCEPTIONS_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: Exceptions.h 1844 2011-05-07 01:51:13Z salnikov $
00007 //
00008 // Description:
00009 //      Class Exceptions.
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------
00014 // C/C++ Headers --
00015 //-----------------
00016 #include <string>
00017 #include <cerrno>
00018 #include <boost/lexical_cast.hpp>
00019 
00020 //----------------------
00021 // Base Class Headers --
00022 //----------------------
00023 #include "ErrSvc/Issue.h"
00024 
00025 //-------------------------------
00026 // Collaborating Class Headers --
00027 //-------------------------------
00028 
00029 //------------------------------------
00030 // Collaborating Class Declarations --
00031 //------------------------------------
00032 
00033 //              ---------------------
00034 //              -- Class Interface --
00035 //              ---------------------
00036 
00037 namespace PSTime {
00038 
00039 /**
00040  *  @brief Base class for exceptions in PSTime package
00041  *
00042  *  This software was developed for the LUSI project.  If you use all or
00043  *  part of it, please give an appropriate acknowledgement.
00044  *
00045  *  @version \$Id: Exceptions.h 1844 2011-05-07 01:51:13Z salnikov $
00046  *
00047  *  @author Andrei Salnikov
00048  */
00049 
00050 /// Base class for all exception classes in a package
00051 class Exception : public ErrSvc::Issue {
00052 public:
00053 
00054   // Constructor
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 /// Exception generated when standard library produces an error with corresponding errno.
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 /// Exception generated for failed clock_gettime() function.
00074 class GetTimeException : public ErrnoException {
00075 public:
00076 
00077   GetTimeException(const ErrSvc::Context& ctx)
00078     : ErrnoException( ctx, "clock_gettime failed") {}
00079 
00080 };
00081 
00082 /// Exception generated for failures during time string parsing.
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 } // namespace PSTime
00092 
00093 #endif // PSTIME_EXCEPTIONS_H

Generated on 19 Dec 2016 for PSANAclasses by  doxygen 1.4.7