Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
roccom_exception.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: roccom_exception.h,v 1.9 2008/12/06 08:43:25 mtcampbe Exp $
24 
25 #ifndef __ROCCOM_EXCEPTION_H__
26 #define __ROCCOM_EXCEPTION_H__
27 
28 #include "roccom_basic.h"
29 #include <string>
30 
31 COM_BEGIN_NAME_SPACE
32 
34 enum Error_code {
59 
61 struct COM_exception {
63  COM_exception( Error_code i, const std::string &m=std::string())
64  : ierr(i), msg(m) {}
67  : ierr(e.ierr), msg(e.msg) {}
68 
70  std::string msg;
71 };
72 
74 std::ostream &operator<<( std::ostream& os, const COM_exception &ex);
75 
77 std::string append_frame_info( const std::string &s, const char *frame,
78  const char *file, int line);
79 
81 #define append_frame( s, frame) \
82  append_frame_info( s, #frame, __FILE__, __LINE__)
83 
86 #define CATCHEXP_APPEND(frame) \
87  catch ( COM_exception e) \
88  { throw COM_exception( e.ierr, append_frame( e.msg, frame)); }
89 
92 #define CATCHBADALLOC_APPEND(frame) \
93  catch ( std::bad_alloc xa) \
94  { throw COM_exception( COM_ERR_OUT_OF_MEMORY, append_frame( "", frame)); }
95 
98 #define CATCHREST_APPEND(frame) \
99  catch (...) \
100  { throw COM_exception( COM_UNKNOWN_ERROR, append_frame( "", frame)); }
101 
102 COM_END_NAME_SPACE
103 
104 #endif
105 
106 
107 
108 
109 
110 
std::string append_frame_info(const std::string &s, const char *frame, const char *file, int line)
Append the information about the given frame to the string s.
double s
Definition: blastest.C:80
Error_code ierr
Error code.
Error_code
Error codes.
This file contains some definitions of macros and constants for Roccoms.
Encapsulates the states of an exception.
std::string msg
Error message.
blockLoc i
Definition: read.cpp:79
COM_exception(const COM_exception &e)
Copy constructor.
std::ostream & operator<<(std::ostream &os, const COM_exception &ex)
Print out a given exception.