exception.C

00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2002 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
00018  */
00019 
00020 #include <iostream>
00021 
00022 #include <omniORB4/CORBA.h>
00023 
00024 #include <archon/util/text.H>
00025 
00026 #include <archon/x3d/proxy/exception.H>
00027 #include <archon/x3d/proxy/sai.H>
00028 
00029 namespace Archon
00030 {
00031   namespace X3D
00032   {
00033     namespace Proxy
00034     {
00035       using namespace std;
00036       using namespace Utilities;
00037 
00038       bool exceptionCatchInfo(Exception::Formatter format, string &result)
00039       {
00040         try { throw; }
00041         catch(x3d::sai::ServerErrorException &e)
00042         {
00043           result = (*format)(typeid(e), "", "'" + string(e.message) + "'");
00044         }
00045         catch(x3d::sai::ApplicationErrorException &e)
00046         {
00047           result = (*format)(typeid(e), "", string(e.message));
00048         }
00049         catch(x3d::sai::FileRequestException &e)
00050         {
00051           result = (*format)(typeid(e), "", string(e.message));
00052         }
00053         catch(x3d::sai::StreamReadException &e)
00054         {
00055           result = (*format)(typeid(e), "", string(e.message));
00056         }
00057         catch(omniORB::fatalException &e)
00058         {
00059           result = (*format)(typeid(e), string(e.file()) + ":" +
00060                   Text::toString(e.line()), e.errmsg());
00061         }
00062         catch(CORBA::Exception &e)
00063         {
00064           result = (*format)(typeid(e), "", "");
00065         }
00066         catch(...)
00067         {
00068           return Utilities::exceptionCatchInfo(format, result);
00069         }
00070         return true;
00071       }
00072 
00073       string exceptionCatchShortExplanation()
00074       {
00075         string message;
00076         if(!exceptionCatchInfo(&Exception::explainShort, message))
00077           message = Exception::explainShortUnknown();
00078         return message;
00079       }
00080     }
00081   }
00082 }
00083 

Generated on Sun Jul 30 22:55:41 2006 for Archon by  doxygen 1.4.4