schwz  Generated automatically from develop
exception_helpers.hpp (35a1195)
1 
2 /*******************************<SCHWARZ LIB LICENSE>***********************
3 Copyright (c) 2019, the SCHWARZ LIB authors
4 All rights reserved.
5 
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
9 
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in the
15 documentation and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its
18 contributors may be used to endorse or promote products derived from
19 this software without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 ******************************<SCHWARZ LIB LICENSE>*************************/
33 
34 #ifndef exception_helpers_hpp
35 #define exception_helpers_hpp
36 
37 
38 #include <exception.hpp>
39 
45 #define SCHWARZ_MODULE_NOT_IMPLEMENTED(module_) \
46  { \
47  throw ::ModuleNotImplemented(__FILE__, __LINE__, module_, __func__); \
48  }
49 
55 #define SCHWARZ_NOT_IMPLEMENTED \
56  { \
57  throw ::NotImplemented(__FILE__, __LINE__, __func__); \
58  }
59 
65 #define SCHWARZ_ASSERT_EQ(_val1, _val2) \
66  if (_val1 != _val2) { \
67  throw ::BadDimension(__FILE__, __LINE__, __func__, " Value ", _val1, \
68  _val2, "expected equal values"); \
69  }
70 
76 #define SCHWARZ_ASSERT_NO_CUSPARSE_ERRORS(_cusparse_call) \
77  do { \
78  auto _errcode = _cusparse_call; \
79  if (_errcode != CUSPARSE_STATUS_SUCCESS) { \
80  throw ::CusparseError(__FILE__, __LINE__, __func__, _errcode); \
81  } \
82  } while (false)
83 
84 
90 #define SCHWARZ_ASSERT_NO_CUDA_ERRORS(_cuda_call) \
91  do { \
92  auto _errcode = _cuda_call; \
93  if (_errcode != cudaSuccess) { \
94  throw ::CudaError(__FILE__, __LINE__, __func__, _errcode); \
95  } \
96  } while (false)
97 
98 
104 #define SCHWARZ_ASSERT_NO_METIS_ERRORS(_metis_call) \
105  do { \
106  auto _errcode = _metis_call; \
107  if (_errcode != METIS_OK) { \
108  throw ::MetisError(__FILE__, __LINE__, __func__, _errcode); \
109  } \
110  } while (false)
111 
112 
118 #define SCHWARZ_ASSERT_NO_UMFPACK_ERRORS(_umfpack_call) \
119  do { \
120  auto _errcode = _umfpack_call; \
121  if (_errcode != UMFPACK_OK) { \
122  throw ::UmfpackError(__FILE__, __LINE__, __func__, _errcode); \
123  } \
124  } while (false)
125 
126 
127 #endif // exception_helpers.hpp