Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:19

0001 #ifndef GENERS_IOEXCEPTION_HH_
0002 #define GENERS_IOEXCEPTION_HH_
0003 
0004 #include <string>
0005 
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 
0008 namespace gs {
0009   /** Base class for the exceptions specific to the Geners I/O library */
0010   struct IOException : public cms::Exception {
0011     inline IOException() : cms::Exception("gs::IOException") {}
0012 
0013     inline explicit IOException(const std::string &description) : cms::Exception(description) {}
0014 
0015     inline explicit IOException(const char *description) : cms::Exception(description) {}
0016 
0017     ~IOException() throw() override {}
0018   };
0019 
0020   struct IOLengthError : public IOException {
0021     inline IOLengthError() : IOException("gs::IOLengthError") {}
0022 
0023     inline explicit IOLengthError(const std::string &description) : IOException(description) {}
0024 
0025     ~IOLengthError() throw() override {}
0026   };
0027 
0028   struct IOOutOfRange : public IOException {
0029     inline IOOutOfRange() : IOException("gs::IOOutOfRange") {}
0030 
0031     inline explicit IOOutOfRange(const std::string &description) : IOException(description) {}
0032 
0033     ~IOOutOfRange() throw() override {}
0034   };
0035 
0036   struct IOInvalidArgument : public IOException {
0037     inline IOInvalidArgument() : IOException("gs::IOInvalidArgument") {}
0038 
0039     inline explicit IOInvalidArgument(const std::string &description) : IOException(description) {}
0040 
0041     ~IOInvalidArgument() throw() override {}
0042   };
0043 
0044   /* Automatic replacement end} */
0045 
0046   /**
0047 // Throw this exception to indicate failure of various stream
0048 // opening methods if it is difficult or impossible to clean up
0049 // after the failure in the normal flow of control
0050 */
0051   class IOOpeningFailure : public IOException {
0052     inline static std::string fileOpeningFailure(const std::string &whereInTheCode, const std::string &filename) {
0053       std::string msg("In ");
0054       msg += whereInTheCode;
0055       msg += ": failed to open file \"";
0056       msg += filename;
0057       msg += "\"";
0058       return msg;
0059     }
0060 
0061   public:
0062     inline IOOpeningFailure() : IOException("gs::IOOpeningFailure") {}
0063 
0064     inline explicit IOOpeningFailure(const std::string &description) : IOException(description) {}
0065 
0066     inline IOOpeningFailure(const std::string &whereInTheCode, const std::string &filename)
0067         : IOException(fileOpeningFailure(whereInTheCode, filename)) {}
0068 
0069     ~IOOpeningFailure() throw() override {}
0070   };
0071 
0072   /**
0073 // Throw this exception to indicate failure in the writing process.
0074 // For example, fail() method of the output stream returns "true",
0075 // and the function is unable to handle this situation locally.
0076 */
0077   struct IOWriteFailure : public IOException {
0078     inline IOWriteFailure() : IOException("gs::IOWriteFailure") {}
0079 
0080     inline explicit IOWriteFailure(const std::string &description) : IOException(description) {}
0081 
0082     ~IOWriteFailure() throw() override {}
0083   };
0084 
0085   /**
0086 // Throw this exception to indicate failure in the reading process.
0087 // For example, fail() method of the input stream returns "true",
0088 // and the function is unable to handle this situation locally.
0089 */
0090   struct IOReadFailure : public IOException {
0091     inline IOReadFailure() : IOException("gs::IOReadFailure") {}
0092 
0093     inline explicit IOReadFailure(const std::string &description) : IOException(description) {}
0094 
0095     ~IOReadFailure() throw() override {}
0096   };
0097 
0098   /**
0099 // Throw this exception when improperly formatted or invalid data
0100 // is detected
0101 */
0102   struct IOInvalidData : public IOException {
0103     inline IOInvalidData() : IOException("gs::IOInvalidData") {}
0104 
0105     inline explicit IOInvalidData(const std::string &description) : IOException(description) {}
0106 
0107     ~IOInvalidData() throw() override {}
0108   };
0109 }  // namespace gs
0110 
0111 #endif  // GENERS_IOEXCEPTION_HH_