TiledArray 1.0.0
Overview
User Guide
Programmer Guides
Source Reference
Modules
Namespace List
Class List
TiledArray
error.h
Go to the documentation of this file.
1
/*
2
* This file is a part of TiledArray.
3
* Copyright (C) 2013 Virginia Tech
4
*
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*
18
*/
19
20
#ifndef TILEDARRAY_ERROR_H__INCLUDED
21
#define TILEDARRAY_ERROR_H__INCLUDED
22
23
#include <TiledArray/config.h>
24
25
#ifndef TA_ASSERT_POLICY
26
#define TA_ASSERT_POLICY TA_ASSERT_THROW
27
#endif
28
29
#define TA_STRINGIZE_IMPL(s) #s
30
#define TA_STRINGIZE(s) TA_STRINGIZE_IMPL(s)
31
32
#define TA_ASSERT_MESSAGE(EXPR, ...) \
33
__FILE__ ":" TA_STRINGIZE(__LINE__) ": " \
34
"TA_ASSERT failed: " TA_STRINGIZE(EXPR)
35
36
#if TA_ASSERT_POLICY == TA_ASSERT_IGNORE
37
#define TA_ASSERT(...) do { } while(0)
38
#else
39
#define TA_ASSERT(EXPR, ...) \
40
do { \
41
if (!(EXPR)) \
42
TiledArray::assert_failed(TA_ASSERT_MESSAGE(EXPR, __VA_ARGS__)); \
43
} while(0)
44
45
#endif
46
47
#include <stdexcept>
48
#include <string>
49
50
namespace
TiledArray
{
51
52
void
ta_abort
();
53
54
void
ta_abort
(
const
std::string &m);
55
56
class
Exception
:
public
std::runtime_error {
57
using
std::runtime_error::runtime_error;
58
};
// class Exception
59
62
inline
void
exception_break
() {}
63
64
inline
void
assert_failed
(
const
std::string &m) {
65
#if TA_ASSERT_POLICY == TA_ASSERT_THROW
66
TiledArray::exception_break
();
67
throw
TiledArray::Exception
(m);
68
#elif TA_ASSERT_POLICY == TA_ASSERT_ABORT
69
TiledArray::ta_abort
(m);
70
#elif TA_ASSERT_POLICY != TA_ASSERT_IGNORE
71
#error Invalid TA_ASSERT_POLICY parameter
72
#endif
73
}
74
75
}
// namespace TiledArray
76
77
#define TA_EXCEPTION_MESSAGE(file, line, mess) \
78
"TiledArray: exception at " file "(" TA_STRINGIZE(line) "): " mess
79
83
#define TA_EXCEPTION(m) \
84
do { \
85
TiledArray::exception_break(); \
86
throw TiledArray::Exception(TA_EXCEPTION_MESSAGE(__FILE__, __LINE__, m)); \
87
} while (0)
88
89
#ifdef TILEDARRAY_NO_USER_ERROR_MESSAGES
90
#define TA_USER_ERROR_MESSAGE(m)
91
#else
92
#include <iostream>
93
#define TA_USER_ERROR_MESSAGE(m) \
94
std::cerr << "!! ERROR TiledArray: " << m << "\n";
95
#endif // TILEDARRAY_NO_USER_ERROR_MESSAGES
96
97
#endif // TILEDARRAY_ERROR_H__INCLUDED
TiledArray::assert_failed
void assert_failed(const std::string &m)
Definition:
error.h:64
TiledArray::ta_abort
void ta_abort()
Definition:
tiledarray.cpp:136
TiledArray::Exception
Definition:
error.h:56
TiledArray
Definition:
array_impl.cpp:28
TiledArray::exception_break
void exception_break()
Definition:
error.h:62
Generated at Sat Apr 24 2021 05:44:20 for
TiledArray
1.0.0 by
1.8.20