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/server/exception.H>
00027 
00028 #include <archon/x3d/sai/exception.H>
00029 #include <archon/x3d/sai/sai.H>
00030 
00031 namespace Archon
00032 {
00033   namespace X3D
00034   {
00035     namespace SAI
00036     {
00037       using namespace std;
00038       using namespace Utilities;
00039 
00040       bool exceptionCatchInfo(Exception::Formatter format, string &result)
00041       {
00042         try { throw; }
00043         catch(x3d::sai::ServerErrorException &e)
00044         {
00045           result = (*format)(typeid(e), "", "'" + string(e.message) + "'");
00046         }
00047         catch(x3d::sai::ApplicationErrorException &e)
00048         {
00049           result = (*format)(typeid(e), "", string(e.message));
00050         }
00051         catch(x3d::sai::FileRequestException &e)
00052         {
00053           result = (*format)(typeid(e), "", string(e.message));
00054         }
00055         catch(x3d::sai::StreamReadException &e)
00056         {
00057           result = (*format)(typeid(e), "", string(e.message));
00058         }
00059         catch(omniORB::fatalException &e)
00060         {
00061           result = (*format)(typeid(e), string(e.file()) + ":" +
00062                   Text::toString(e.line()), e.errmsg());
00063         }
00064         catch(CORBA::Exception &e)
00065         {
00066           result = (*format)(typeid(e), "", "");
00067         }
00068         catch(...)
00069         {
00070           return X3D::exceptionCatchInfo(format, result);
00071         }
00072         return true;
00073       }
00074 
00075       string exceptionCatchShortExplanation()
00076       {
00077         string message;
00078         if(!exceptionCatchInfo(&Exception::explainShort, message))
00079           message = Exception::explainShortUnknown();
00080         return message;
00081       }
00082     }
00083   }
00084 }
00085 

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