exception.hpp
Go to the documentation of this file.
1// $Id: exception.hpp 1107 2012-11-06 08:40:41Z perroe $
2
3// Copyright (c) 2011, Norwegian Computing Center
4// All rights reserved.
5// Redistribution and use in source and binary forms, with or without modification,
6// are permitted provided that the following conditions are met:
7// • Redistributions of source code must retain the above copyright notice, this
8// list of conditions and the following disclaimer.
9// • Redistributions in binary form must reproduce the above copyright notice, this list of
10// conditions and the following disclaimer in the documentation and/or other materials
11// provided with the distribution.
12// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
13// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
15// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
16// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
17// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
18// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
20// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21
22#ifndef NRLIB_EXCEPTION_HPP
23#define NRLIB_EXCEPTION_HPP
24
25#include <exception>
26#include <string>
27
28//Test: Information flows from external back to original?
29//Test: And of course it flows downwards?
30
31namespace NRLib {
32
33class Exception : public std::exception
34{
35public:
36 explicit Exception(const std::string& msg = "") : msg_(msg) { }
37 virtual ~Exception() throw() {}
38 virtual const char * what() const throw() {return msg_.c_str();}
39private:
40 std::string msg_;
41};
42
44{
45public:
46 explicit IndexOutOfRange(const std::string& msg = "")
47 : Exception(msg) {}
48
49 virtual ~IndexOutOfRange() throw() {}
50};
51
52class FFTError : public Exception
53{
54public:
55 explicit FFTError(const std::string& msg = "")
56 : Exception(msg) {}
57
58 virtual ~FFTError() throw() {}
59};
60
61class IOError : public Exception
62{
63public:
64 explicit IOError(const std::string& msg = "")
65 : Exception(msg) {}
66
67 virtual ~IOError() throw() {}
68};
69
71{
72public:
73 explicit FileFormatError(const std::string& msg = "")
74 : IOError(msg) {}
75
76 virtual ~FileFormatError() throw() {}
77};
78
79class EndOfFile : public IOError
80{
81public:
82 explicit EndOfFile(const std::string& msg = "")
83 : IOError(msg) {}
84
85 virtual ~EndOfFile() throw() {}
86};
87
88class JobCanceled : public Exception
89{
90public:
91 explicit JobCanceled(const std::string& msg = "")
92 : Exception(msg) {}
93
94 virtual ~JobCanceled() throw() {}
95};
96
97}
98
99#endif
const char *const string
Definition: cJSON.h:170
Definition: exception.hpp:80
virtual ~EndOfFile()
Definition: exception.hpp:85
EndOfFile(const std::string &msg="")
Definition: exception.hpp:82
Definition: exception.hpp:34
Exception(const std::string &msg="")
Definition: exception.hpp:36
virtual const char * what() const
Definition: exception.hpp:38
virtual ~Exception()
Definition: exception.hpp:37
Definition: exception.hpp:53
FFTError(const std::string &msg="")
Definition: exception.hpp:55
virtual ~FFTError()
Definition: exception.hpp:58
Definition: exception.hpp:71
FileFormatError(const std::string &msg="")
Definition: exception.hpp:73
virtual ~FileFormatError()
Definition: exception.hpp:76
Definition: exception.hpp:62
virtual ~IOError()
Definition: exception.hpp:67
IOError(const std::string &msg="")
Definition: exception.hpp:64
Definition: exception.hpp:44
virtual ~IndexOutOfRange()
Definition: exception.hpp:49
IndexOutOfRange(const std::string &msg="")
Definition: exception.hpp:46
Definition: exception.hpp:89
JobCanceled(const std::string &msg="")
Definition: exception.hpp:91
virtual ~JobCanceled()
Definition: exception.hpp:94
Definition: exception.hpp:31