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

Last change on this file since 751 was 751, checked in by Jari Häkkinen, 16 years ago

Addresses #2. Continued adding GSL_error exceptions.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1#ifndef _theplu_yat_utility_exception_
2#define _theplu_yat_utility_exception_
3
4// $Id: Exception.h 751 2007-02-17 12:25:36Z jari $
5
6/*
7  Copyright (C) 2005 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2006 Jari Häkkinen
9
10  This file is part of the yat library, http://lev.thep.lu.se/trac/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 2 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 this program; if not, write to the Free Software
24  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25  02111-1307, USA.
26*/
27
28#include <stdexcept>
29#include <string>
30
31#include <gsl/gsl_errno.h>
32
33namespace theplu {
34namespace yat {
35namespace utility {
36
37  /**
38     \brief Class for errors reported from underlying GSL calls.
39  */
40  class GSL_error : public std::runtime_error
41  {
42  public:
43    /**
44       \brief The default constructor
45    */
46    inline GSL_error(void) throw() : std::runtime_error("GSL_error:") {}
47
48    /**
49       \brief Constructor to create an exception with a message
50    */
51    inline GSL_error(std::string message) throw()
52      : std::runtime_error("GSL_error: " + message) {}
53
54    inline GSL_error(std::string message, int gsl_status) throw()
55      : std::runtime_error("GSL_error: " + message + " " +
56                           gsl_strerror(gsl_status)) {}
57  };
58
59
60  ///
61  /// @brief Class for IO errors
62  ///
63  class IO_error : public std::runtime_error
64  {
65  public:
66    ///
67    /// Default constructor
68    ///
69    inline IO_error(void) throw() : std::runtime_error("IO_error:") {}
70
71    /**
72       \brief Constructor to create an exception with a message
73    */
74    inline IO_error(std::string message) throw()
75      : std::runtime_error("IO_error: " + message) {}
76  };
77
78}}} // of namespace utility, yat, and theplu
79
80#endif
Note: See TracBrowser for help on using the repository browser.