SIRF
3.4.0
sources
SIRF
src
iUtilities
include
sirf
iUtilities
LocalisedException.h
1
/*
2
SyneRBI Synergistic Image Reconstruction Framework (SIRF)
3
Copyright 2015 - 2020 Rutherford Appleton Laboratory STFC
4
5
This is software developed for the Collaborative Computational
6
Project in Synergistic Reconstruction for Biomedical Imaging (formerly CCP PETMR)
7
(http://www.ccpsynerbi.ac.uk/).
8
9
Licensed under the Apache License, Version 2.0 (the "License");
10
you may not use this file except in compliance with the License.
11
You may obtain a copy of the License at
12
http://www.apache.org/licenses/LICENSE-2.0
13
Unless required by applicable law or agreed to in writing, software
14
distributed under the License is distributed on an "AS IS" BASIS,
15
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
See the License for the specific language governing permissions and
17
limitations under the License.
18
19
*/
20
21
#ifndef LOCALISED_EXCEPTION
22
#define LOCALISED_EXCEPTION
23
24
#include <string.h>
25
26
#include <exception>
27
#include <iostream>
28
29
#define THROW(msg) throw LocalisedException(msg, __FILE__, __LINE__)
30
#define ASSERT(condition, msg) if (!(condition)) THROW(msg)
31
32
class
LocalisedException
:
public
std::exception {
33
public
:
34
LocalisedException
(
const
std::string& reason,
const
std::string& file,
int
line)
35
: reason_(reason), file_(file), line_(line)
36
{ }
37
virtual
~
LocalisedException
()
throw
()
38
{ }
39
virtual
const
char
* what()
const
throw
()
40
{
41
return
reason_.c_str();
42
}
43
const
std::string& file()
const
throw
()
44
{
45
return
file_;
46
}
47
int
line()
const
throw
() {
48
return
line_;
49
}
50
private
:
51
const
std::string reason_;
52
const
std::string file_;
53
int
line_;
54
};
55
56
#endif
LocalisedException
Definition:
LocalisedException.h:32
Generated by
1.8.13