PSEnv/src/Exceptions.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: Exceptions.cpp 4204 2012-07-24 17:09:03Z salnikov@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class Exceptions...
00007 //
00008 // Author List:
00009 //      Andrei Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "PSEnv/Exceptions.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 #include <cxxabi.h>
00022 #include <stdlib.h>
00023 
00024 //-------------------------------
00025 // Collaborating Class Headers --
00026 //-------------------------------
00027 
00028 //-----------------------------------------------------------------------
00029 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00030 //-----------------------------------------------------------------------
00031 
00032 namespace {
00033   
00034   std::string typeName(const std::type_info& typeinfo)
00035   {
00036     int status;
00037     char* realname = abi::__cxa_demangle(typeinfo.name(), 0, 0, &status);
00038     std::string name = realname;
00039     free(realname);
00040     return name;
00041   }
00042   
00043 }
00044 
00045 //              ----------------------------------------
00046 //              -- Public Function Member Definitions --
00047 //              ----------------------------------------
00048 
00049 namespace PSEnv {
00050 
00051 Exception::Exception( const ErrSvc::Context& ctx, const std::string& what )
00052   : ErrSvc::Issue( ctx, "PSEnv::Exception: " + what )
00053 {
00054 }
00055 
00056 ExceptionEpicsName::ExceptionEpicsName ( const ErrSvc::Context& ctx, 
00057                                          const std::string& pvname ) 
00058   : Exception( ctx, "unknown EPICS PV name: " + pvname)
00059 {  
00060 }
00061 
00062 ExceptionEpicsConversion::ExceptionEpicsConversion ( const ErrSvc::Context& ctx, 
00063                                                      const std::string& pvname,
00064                                                      const std::type_info& ti,
00065                                                      const std::string& what)
00066   : Exception( ctx, "error converting PV value: PV=" + pvname +
00067       ", result type=" + ::typeName(ti) + ", error: " + what )
00068 {
00069 }
00070 
00071 } // namespace PSEnv

Generated on 19 Dec 2016 for PSANAclasses by  doxygen 1.4.7