DFT-EFE
 
Loading...
Searching...
No Matches
Exceptions.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21
22/*
23 * @author Bikash Kanungo
24 */
25#ifndef dftefeExceptions_h
26#define dftefeExceptions_h
27
28#include <string>
29#include <stdexcept>
86#undef DFTEFE_Assert
87#undef DFTEFE_AssertWithMsg
88
89#if defined(DFTEFE_DISABLE_ASSERT) || \
90 (!defined(DFTEFE_ENABLE_ASSERT) && defined(NDEBUG))
91# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
92# define DFTEFE_Assert(expr) ((void)0)
93# define DFTEFE_AssertWithMsg(expr, msg) ((void)0)
94
95#elif defined(DFTEFE_ENABLE_ASSERT) && defined(NDEBUG)
96# undef NDEBUG // disabling NDEBUG to forcibly enable assert for sources that
97 // set DFTEFE_ENABLE_ASSERT even when in release mode (with
98 // NDEBUG)
99# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
100# define DFTEFE_Assert(expr) assert(expr)
101# define DFTEFE_AssertWithMsg(expr, msg) assert((expr) && (msg))
102
103#else
104# include <assert.h> // .h to support old libraries w/o <cassert> - effect is the same
105# define DFTEFE_Assert(expr) assert(expr)
106# define DFTEFE_AssertWithMsg(expr, msg) assert((expr) && (msg))
107
108#endif
109
110#ifdef DFTEFE_WITH_DEVICE_CUDA
111# include <utils/DeviceExceptions.cuh>
112#endif
113
114namespace dftefe
115{
116 namespace utils
117 {
118 typedef std::logic_error LogicError;
119 typedef std::invalid_argument InvalidArgument;
120 typedef std::domain_error DomainError;
121 typedef std::length_error LengthError;
122 typedef std::out_of_range OutOfRangeError;
123 typedef std::runtime_error RuntimeError;
124 typedef std::overflow_error OverflowError;
125 typedef std::underflow_error UnderflowError;
126
127 void
128 throwException(bool condition, std::string msg = "");
129
130 template <class T>
131 void
132 throwException(bool condition, std::string msg = "");
133
134 } // namespace utils
135} // namespace dftefe
136#include "Exceptions.t.cpp"
137#endif // dftefeExceptions_h
std::runtime_error RuntimeError
Definition: Exceptions.h:123
std::domain_error DomainError
Definition: Exceptions.h:120
std::underflow_error UnderflowError
Definition: Exceptions.h:125
std::out_of_range OutOfRangeError
Definition: Exceptions.h:122
void throwException(bool condition, std::string msg)
Definition: Exceptions.cpp:56
std::logic_error LogicError
Definition: Exceptions.h:118
std::length_error LengthError
Definition: Exceptions.h:121
std::overflow_error OverflowError
Definition: Exceptions.h:124
std::invalid_argument InvalidArgument
Definition: Exceptions.h:119
dealii includes
Definition: AtomFieldDataSpherical.cpp:31