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

Last change on this file since 1679 was 1487, checked in by Jari Häkkinen, 13 years ago

Addresses #436. GPL license copy reference should also be updated.

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