1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 class Exception {
21 public:
22
23 #if 0
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
45
46
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
52
53
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
68 PMPI::Exception pmpi_exception;
69 #else
70 int error_code;
71 char* error_string;
72 int error_class;
73 #endif
74 };