/usr/include/CGAL/exceptions.h is in libcgal-dev 4.11-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | // Copyright (c) 2006 INRIA Sophia-Antipolis (France) and
// Max-Planck-Institute Saarbruecken (Germany).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Lutz Kettner, Sylvain Pion
#ifndef CGAL_EXCEPTIONS_H
#define CGAL_EXCEPTIONS_H
#include <CGAL/config.h>
#include <stdexcept>
#include <string>
#include <boost/lexical_cast.hpp>
namespace CGAL {
// [Sylvain] This was originaly written in the Exacus library.
// I kept most doxygen comments.
/*! \defgroup CGAL_assert Assertions
\brief <tt>\#include <CGAL/basic.h></tt> for pre- and postconditions,
assertions, warnings, and error handler.
\c CGAL/basic.h provides macros for pre- and postconditions, assertions,
warnings, and errors that are active by default. There are variants
for expensive checks that are inactive by default.
A failed precondition, postcondition or assertion is a fatal error
and the library aborts by default the program execution. For warnings
the program continues to run. Both can be changed with the respective
\c error_behavior or \c warning_behavior, or with the corresponding
\c error_handler or \c warning_handler.
However, if the checks are disabled with corresponding
preprocessor symbols or \c NDEBUG, none of this error handling
will happen and the program execution continues with potentially
disastrous results. So, these checks are not for normal error
handling, for example testing proper user input or file
formats. Furthermore, it is recommended to keep the checks also in
the production version of the program, keeping in mind that they
should not cost too much runtime overhead, maybe 10%.
\see \c CGAL_test for checks that cannot be disabled and
\c CGAL_error_msg for an unconditional error message that cannot
be disabled with macros.
*/
//@{
// Failure types and exceptions
// ============================
//! Exception base class for all failure types of assertions etc.
class Failure_exception : public std::logic_error {
std::string m_lib;
std::string m_expr; // can be empty
std::string m_file;
int m_line;
std::string m_msg; // can be empty
public:
//! initializes local members and the <tt>std::logic_error</tt> with
//! a suitable message.
Failure_exception( std::string lib,
std::string expr,
std::string file,
int line,
std::string msg,
std::string kind = "Unknown kind") :
std::logic_error( lib + std::string( " ERROR: ") + kind + std::string( "!")
+ ((expr.empty()) ? (std::string("")) : (std::string("\nExpr: ")+expr))
+ std::string( "\nFile: ") + file
+ std::string( "\nLine: ") + boost::lexical_cast<std::string>(line)
+ ((msg.empty()) ? (std::string(""))
: (std::string("\nExplanation: ") + msg))),
m_lib( lib),
m_expr( expr),
m_file( file),
m_line( line),
m_msg( msg)
{}
~Failure_exception() throw() {}
//! the name of the library that issues this message.
std::string library() const { return m_lib; }
//! expression that failed in assertion, pre-, or postcondition.
std::string expression() const { return m_expr; }
//! source code filename where the failure was detected.
std::string filename() const { return m_file; }
//! line number in source code file where the failure was detected.
int line_number() const { return m_line; }
//! an optional message explaining the kind of failure.
std::string message() const { return m_msg; }
};
//! Exception thrown for \c CGAL_error_msg.
class Error_exception : public Failure_exception {
public:
Error_exception( std::string lib,
std::string msg,
std::string file,
int line)
: Failure_exception( lib, "", file, line, msg, "failure" ) {}
};
//! Exception thrown for \c CGAL_precond.
class Precondition_exception : public Failure_exception {
public:
Precondition_exception( std::string lib,
std::string expr,
std::string file,
int line,
std::string msg)
: Failure_exception( lib, expr, file, line, msg,
"precondition violation") {}
};
//! Exception thrown for \c CGAL_postcond.
class Postcondition_exception : public Failure_exception {
public:
Postcondition_exception( std::string lib,
std::string expr,
std::string file,
int line,
std::string msg)
: Failure_exception( lib, expr, file, line, msg,
"postcondition violation") {}
};
//! Exception thrown for \c CGAL_assert.
class Assertion_exception : public Failure_exception {
public:
Assertion_exception( std::string lib,
std::string expr,
std::string file,
int line,
std::string msg)
: Failure_exception( lib, expr, file, line, msg,
"assertion violation") {}
};
//! Exception thrown for \c CGAL_test.
class Test_exception : public Failure_exception {
public:
Test_exception( std::string lib,
std::string expr,
std::string file,
int line,
std::string msg)
: Failure_exception( lib, expr, file, line, msg,
"test in test-suite violation") {}
};
//! Exception thrown for \c CGAL_warning.
class Warning_exception : public Failure_exception {
public:
Warning_exception( std::string lib,
std::string expr,
std::string file,
int line,
std::string msg)
: Failure_exception( lib, expr, file, line, msg,
"warning condition failed") {}
};
} //namespace CGAL
#endif // CGAL_EXCEPTIONS_H
|