1 // -*- c++ -*-
2 //
3 // Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4 // University Research and Technology
5 // Corporation. All rights reserved.
6 // Copyright (c) 2004-2005 The University of Tennessee and The University
7 // of Tennessee Research Foundation. All rights
8 // reserved.
9 // Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10 // University of Stuttgart. All rights reserved.
11 // Copyright (c) 2004-2005 The Regents of the University of California.
12 // All rights reserved.
13 // $COPYRIGHT$
14 //
15 // Additional copyrights may follow
16 //
17 // $HEADER$
18 //
19
20 class Exception {
21 public:
22
23 #if 0 /* OMPI_ENABLE_MPI_PROFILING */
24
25 inline Exception(int ec) : pmpi_exception(ec) { }
26
27 int Get_error_code() const;
28
29 int Get_error_class() const;
30
31 const char* Get_error_string() const;
32
33 #else
34
35 inline Exception(int ec) : error_code(ec), error_string(0), error_class(-1) {
36 (void)MPI_Error_class(error_code, &error_class);
37 int resultlen;
38 error_string = new char[MAX_ERROR_STRING];
39 (void)MPI_Error_string(error_code, error_string, &resultlen);
40 }
41 inline ~Exception() {
42 delete[] error_string;
43 }
44 // Better put in a copy constructor here since we have a string;
45 // copy by value (from the default copy constructor) would be
46 // disasterous.
47 inline Exception(const Exception& a)
48 : error_code(a.error_code), error_class(a.error_class)
49 {
50 error_string = new char[MAX_ERROR_STRING];
51 // Rather that force an include of <string.h>, especially this
52 // late in the game (recall that this file is included deep in
53 // other .h files), we'll just do the copy ourselves.
54 for (int i = 0; i < MAX_ERROR_STRING; i++)
55 error_string[i] = a.error_string[i];
56 }
57
58 inline int Get_error_code() const { return error_code; }
59
60 inline int Get_error_class() const { return error_class; }
61
62 inline const char* Get_error_string() const { return error_string; }
63
64 #endif
65
66 protected:
67 #if 0 /* OMPI_ENABLE_MPI_PROFILING */
68 PMPI::Exception pmpi_exception;
69 #else
70 int error_code;
71 char* error_string;
72 int error_class;
73 #endif
74 };