00001 #include "CorbaExceptionWrapper.h"
00002
00003 namespace Sct {
00004
00005
00006
00007 std::string CorbaExceptionWrapper::whatDoesThisCORBAExceptionTellUs(const CORBA::Exception & error) throw() {
00008
00009 try {
00010 std::ostringstream os;
00011 os << "CorbaExceptionWrapper[";
00012
00013 os << "_name=[";
00014 try {
00015 os << error._name() << "], ";
00016 } catch(...) {
00017 os << "oops], ";
00018 };
00019
00020
00021 const CORBA::SystemException * sysEx = dynamic_cast<const CORBA::SystemException*>(&error);
00022 {
00023 if (sysEx) {
00024 os << "is a CORBA::SystemException with ";
00025 os << "NP_minorString=[";
00026 try {
00027 const std::string minorString = sysEx->NP_minorString();
00028 os << minorString << "], ";
00029 if (minorString=="TRANSIENT_CallTimedout") {
00030 os << "(sometimes you see this message because one of your CORBA methods took longer to return than the interval in milliseconds defined by TDAQ_IPC_TIMEOUT which is read by Sergei's ipc package, part of the TDAQ online software. See http://www.hep.phy.cam.ac.uk/daq-bin/wiki.cgi/CorbaExceptions or grep for TDAQ_IPC_TIMEOUT in the online software. Last seen in online-00-22-00/installed/../ipc/ipc-04-00-09/src/core.cc. Fix the core problem by making your pc calls non blocking, or work around by adding TDAQ_IPC_TIMEOUT to the environment of the program. See diff between versions 1.2 and 1.3 of config/databases/SCT_core.data.xml for example.), ";
00031 };
00032 } catch(...) {
00033 os << "oops], ";
00034 };
00035
00036 os << "minorCode=[";
00037 try {
00038 os << sysEx->minor() << "]";
00039 } catch(...) {
00040 os << "oops]";
00041 };
00042 } else {
00043 os << "end";
00044 };
00045 }
00046 os << ".";
00047
00048 return os.str();
00049
00050 } catch (...) {
00051
00052 return "Oh dear ... something broke while trying to find out what this CORBA::Exception was made of so I can't tell you anything about it!";
00053
00054 };
00055 };
00056
00057 CorbaExceptionWrapper::CorbaExceptionWrapper(const CORBA::Exception& error, const string& msg, const string& file, int line) throw() {
00058
00059 try {
00060 std::ostringstream os;
00061
00062 os << "CorbaExceptionWrapper created with requested message=["<<msg<<"] and requested FILE=["<<file<<"] and requested line=["<<line<<"]. In addition the wrapped CORBA::Exception reports: [" << whatDoesThisCORBAExceptionTellUs(error) << "]";
00063
00064 const std::string longMessage = os.str();
00065 initialize("CORBA_EXCEPTION", "Sct::CorbaExceptionWrapper", longMessage, 0, file, line);
00066
00067 name=error._name();
00068
00069 } catch (...) {
00070
00071 initialize("CORBA_EXCEPTION", "Sct::CorbaExceptionWrapper", "Something terrible happened while wrapping whatever this exception was so I can't tell you much about it!", 0, file, line);
00072
00073 name="Sorry, not known!";
00074
00075 };
00076 }
00077
00078 CorbaExceptionWrapper::~CorbaExceptionWrapper() throw() {}
00079
00080 shared_ptr<Throwable> CorbaExceptionWrapper::clone() const throw() {
00081 return shared_ptr<Throwable>(new CorbaExceptionWrapper(*this));
00082 }
00083
00084 string CorbaExceptionWrapper::getMessage() const throw() {
00085 return m_name;
00086 }
00087
00088
00089 }