hpp-util
4.13.0
Debugging tools for the HPP project.
exception.hh
Go to the documentation of this file.
1
// Copyright (C) 2010 by Thomas Moulard, CNRS.
2
//
3
4
// Redistribution and use in source and binary forms, with or without
5
// modification, are permitted provided that the following conditions are
6
// met:
7
//
8
// 1. Redistributions of source code must retain the above copyright
9
// notice, this list of conditions and the following disclaimer.
10
//
11
// 2. Redistributions in binary form must reproduce the above copyright
12
// notice, this list of conditions and the following disclaimer in the
13
// documentation and/or other materials provided with the distribution.
14
//
15
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26
// DAMAGE.
27
//
28
// This software is provided "as is" without warranty of any kind,
29
// either expressed or implied, including but not limited to the
30
// implied warranties of fitness for a particular purpose.
31
//
32
// See the COPYING file for more information.
33
35
36
#ifndef HPP_UTIL_EXCEPTION_HH
37
#define HPP_UTIL_EXCEPTION_HH
38
#include <
hpp/util/config.hh
>
39
#include <iosfwd>
40
#include <stdexcept>
41
#include <string>
42
43
namespace
hpp
{
47
class
HPP_UTIL_DLLAPI
Exception
:
public
std::exception {
48
public
:
49
Exception
(
const
std::string& message,
const
std::string& file,
50
unsigned
line)
throw
();
51
~
Exception
()
throw
();
52
Exception
(
const
Exception
& exception)
throw
();
53
Exception
& operator=(
const
Exception
& exception)
throw
();
54
55
virtual
const
char
* what()
const
throw
();
56
61
virtual
std::ostream& print(std::ostream& o)
const
throw
();
62
63
private
:
64
std::string message_;
65
std::string file_;
66
unsigned
line_;
67
};
68
74
HPP_UTIL_DLLAPI
std::ostream&
operator<<
(std::ostream& o,
75
const
Exception
& exception);
76
77
}
// end of namespace hpp.
78
80
#define HPP_THROW_EXCEPTION_(MSG) \
81
throw ::hpp::Exception(MSG, __FILE__, __LINE__)
82
84
#define HPP_THROW_EXCEPTION(TYPE, MSG) throw TYPE(MSG, __FILE__, __LINE__)
85
87
#define HPP_MAKE_EXCEPTION(EXTRA_QUALIFIER, TYPE) \
88
class EXTRA_QUALIFIER TYPE : public ::hpp::Exception { \
89
public: \
90
TYPE(const std::string& message, const std::string& file, unsigned line) \
91
throw() : ::hpp::Exception(message, file, line) {} \
92
}
93
95
#define HPP_MAKE_EXCEPTION_NO_QUALIFIER(TYPE) \
96
class TYPE : public ::hpp::Exception { \
97
public: \
98
TYPE(const std::string& message, const std::string& file, unsigned line) \
99
throw() : ::hpp::Exception(message, file, line) {} \
100
}
101
102
#endif
hpp::operator<<
HPP_UTIL_DLLAPI std::ostream & operator<<(std::ostream &o, const Exception &exception)
Override operator<< to handle exception display.
Definition:
exception.cc:79
HPP_UTIL_DLLAPI
#define HPP_UTIL_DLLAPI
Definition:
config.hh:64
hpp
Definition:
assertion.hh:45
hpp::Exception
Main exception class for HPP.
Definition:
exception.hh:47
config.hh
include
hpp
util
exception.hh
Generated by
1.8.17