Back to index

salome-kernel  6.5.0
Utils_CorbaException.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SALOME Utils : general SALOME's definitions and tools
00024 //  File   : Utils_CorbaException.hxx
00025 //  Author : Paul RASCLE, EDF
00026 //  Module : SALOME
00027 //  $Header: /home/server/cvs/KERNEL/KERNEL_SRC/src/Utils/Utils_CorbaException.hxx,v 1.9.30.2.12.1 2012-04-12 14:05:32 vsr Exp $
00028 //
00029 #ifndef _UTILS_CORBAEXCEPTION_HXX_
00030 #define _UTILS_CORBAEXCEPTION_HXX_
00031 
00032 #include "SALOME_Utils.hxx"
00033 
00034 #include <SALOMEconfig.h>
00035 #include CORBA_SERVER_HEADER(SALOME_Exception)
00036 
00040 # define THROW_SALOME_CORBA_EXCEPTION(chain, typex) \
00041               {\
00042                 SALOME::ExceptionStruct ExDescription; \
00043                 ExDescription.text = CORBA::string_dup(chain); \
00044                 ExDescription.type = typex; \
00045                 ExDescription.sourceFile = CORBA::string_dup(__FILE__); \
00046                 ExDescription.lineNumber = __LINE__; \
00047                 throw SALOME::SALOME_Exception(ExDescription); \
00048               }
00049 
00050 #include <ostream>
00051 
00052 //Dump the CORBA exception type.
00053 inline std::ostream& operator<<(std::ostream& os, const CORBA::Exception& e)
00054 {
00055   CORBA::Any tmp;
00056   tmp<<= e;
00057   CORBA::TypeCode_var tc = tmp.type();
00058   const char *p = tc->name();
00059   os<<"CORBA Exception was catch of the kind : ";
00060   if ( *p != '\0' ) {
00061     os<<p;
00062   } 
00063   else  { 
00064     os << tc->id();
00065   }
00066   
00067   return os;
00068 }
00069 
00070 #endif