CMS 3D CMS Logo

ErrorThrower.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     FWLite
00004 // Class  :     ErrorThrower
00005 // 
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Tue Sep 23 10:06:39 EDT 2008
00011 // $Id: ErrorThrower.cc,v 1.2 2008/09/23 16:35:07 dsr Exp $
00012 //
00013 
00014 // system include files
00015 
00016 // user include files
00017 #include "DataFormats/FWLite/interface/ErrorThrower.h"
00018 #include "FWCore/Utilities/interface/EDMException.h"
00019 #include "FWCore/Utilities/interface/TypeID.h"
00020 
00021 using namespace fwlite;
00022 //
00023 // constants, enums and typedefs
00024 //
00025 namespace {
00026    class NoProductErrorThrower : public ErrorThrower {
00027    public:
00028       NoProductErrorThrower(const std::type_info& iType, const char*iModule, const char*iInstance, const char*iProcess):
00029       type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
00030       
00031       void throwIt() const {
00032 
00033          edm::TypeID type(*type_);
00034          throw edm::Exception(edm::errors::ProductNotFound)<<"A branch was found for \n  type ='"<<type.className()<<"'\n  module='"<<module_
00035          <<"'\n  productInstance='"<<((0!=instance_)?instance_:"")<<"'\n  process='"<<((0!=process_)?process_:"")<<"'\n"
00036          "but no data is available for this Event";
00037       }
00038       virtual ErrorThrower* clone() const {
00039          return new NoProductErrorThrower(*this);
00040       }
00041 
00042    private:
00043       const std::type_info* type_;
00044       const char* module_;
00045       const char* instance_;
00046       const char* process_;
00047    };
00048    
00049    class NoBranchErrorThrower : public ErrorThrower {
00050    public:
00051       NoBranchErrorThrower(const std::type_info& iType, const char*iModule, const char*iInstance, const char*iProcess):
00052       type_(&iType), module_(iModule), instance_(iInstance), process_(iProcess) {}
00053       
00054       void throwIt() const {
00055          
00056          edm::TypeID type(*type_);
00057          throw edm::Exception(edm::errors::ProductNotFound)<<"No branch was found for \n  type ='"<<type.className()<<"'\n  module='"<<module_
00058          <<"'\n  productInstance='"<<((0!=instance_)?instance_:"")<<"'\n  process='"<<((0!=process_)?process_:"")<<"'";
00059       }
00060       
00061       virtual ErrorThrower* clone() const {
00062          return new NoBranchErrorThrower(*this);
00063       }
00064       
00065    private:
00066       const std::type_info* type_;
00067       const char* module_;
00068       const char* instance_;
00069       const char* process_;
00070    };
00071    
00072    class UnsetErrorThrower : public ErrorThrower {
00073       void throwIt() const {
00074          throw cms::Exception("UnsetHandle")<<"The fwlite::Handle was never set";
00075       }
00076       
00077       virtual ErrorThrower* clone() const {
00078          return new UnsetErrorThrower(*this);
00079       }
00080       
00081    };
00082 }
00083 //
00084 // static data member definitions
00085 //
00086 
00087 //
00088 // constructors and destructor
00089 //
00090 ErrorThrower::ErrorThrower()
00091 {
00092 }
00093 
00094 // ErrorThrower::ErrorThrower(const ErrorThrower& rhs)
00095 // {
00096 //    // do actual copying here;
00097 // }
00098 
00099 ErrorThrower::~ErrorThrower()
00100 {
00101 }
00102 
00103 //
00104 // assignment operators
00105 //
00106 // const ErrorThrower& ErrorThrower::operator=(const ErrorThrower& rhs)
00107 // {
00108 //   //An exception safe implementation is
00109 //   ErrorThrower temp(rhs);
00110 //   swap(rhs);
00111 //
00112 //   return *this;
00113 // }
00114 
00115 //
00116 // member functions
00117 //
00118 
00119 //
00120 // const member functions
00121 //
00122 
00123 //
00124 // static member functions
00125 //
00126 ErrorThrower* 
00127 ErrorThrower::unsetErrorThrower() {
00128    return new UnsetErrorThrower();
00129 }
00130 
00131 ErrorThrower* 
00132 ErrorThrower::errorThrowerBranchNotFoundException(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess){
00133    return new NoBranchErrorThrower(iType,iModule,iInstance,iProcess);
00134 }
00135 
00136 ErrorThrower* 
00137 ErrorThrower::errorThrowerProductNotFoundException(const std::type_info& iType, const char* iModule, const char* iInstance, const char* iProcess){
00138    return new NoProductErrorThrower(iType,iModule,iInstance,iProcess);
00139 }

Generated on Tue Jun 9 17:30:47 2009 for CMSSW by  doxygen 1.5.4