source: trunk/yat/utility/Exception.h @ 1797

Last change on this file since 1797 was 1797, checked in by Peter, 13 years ago

updating copyright statements

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1#ifndef _theplu_yat_utility_exception_
2#define _theplu_yat_utility_exception_
3
4// $Id: Exception.h 1797 2009-02-12 18:07:10Z peter $
5
6/*
7  Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson
8
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include <stdexcept>
26#include <string>
27
28#include <gsl/gsl_errno.h>
29
30namespace theplu {
31namespace yat {
32namespace utility {
33
34  /**
35     \brief Class used for error reported from Commandline or Option.
36   */
37  class cmd_error : public std::runtime_error
38  {
39  public:
40    /**
41       \brief Constructor
42
43       \param message message to be displayed using function what().
44     */
45    inline cmd_error(std::string message)
46      : std::runtime_error(message) {}
47  };
48
49
50  /**
51     \brief Class for errors reported from underlying GSL calls.
52
53     GSL_error is used in the same way as C++ standard library
54     exceptions.
55  */
56  class GSL_error : public std::runtime_error
57  {
58  public:
59    /**
60       \brief Constructor to create an exception with a message.
61    */
62    inline GSL_error(std::string message) throw()
63      : std::runtime_error("GSL_error: " + message) {}
64
65    /**
66       \brief Constructor to create an exception with a message
67       containg the GSL error description.
68    */
69    inline GSL_error(std::string message, int gsl_status) throw()
70      : std::runtime_error("GSL_error: " + message + " " +
71                           gsl_strerror(gsl_status)) {}
72  };
73
74
75  /**
76     \brief Class to report errors associated with IO operations.
77
78     IO_error is used in the same way as C++ standard library
79     exceptions.
80  */
81  class IO_error : public std::runtime_error
82  {
83  public:
84    /**
85       \brief Constructor to create an exception with a message.
86    */
87    inline IO_error(std::string message) throw()
88      : std::runtime_error("IO_error: " + message) {}
89  };
90
91}}} // of namespace utility, yat, and theplu
92
93#endif
Note: See TracBrowser for help on using the repository browser.