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

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

Fixes #7.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1#ifndef _theplu_yat_utility_exception_
2#define _theplu_yat_utility_exception_
3
4// $Id: Exception.h 761 2007-02-20 17:26:05Z jari $
5
6/*
7  Copyright (C) 2005 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2006, 2007 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     GSL_error is used in the same way as C++ standard library
41     exceptions.
42  */
43  class GSL_error : public std::runtime_error
44  {
45  public:
46    /**
47       \brief Constructor to create an exception with a message.
48    */
49    inline GSL_error(std::string message) throw()
50      : std::runtime_error("GSL_error: " + message) {}
51
52    /**
53       \brief Constructor to create an exception with a message
54       containg the GSL error description.
55    */
56    inline GSL_error(std::string message, int gsl_status) throw()
57      : std::runtime_error("GSL_error: " + message + " " +
58                           gsl_strerror(gsl_status)) {}
59  };
60
61
62  /**
63     \brief Class to report errors associated with IO operations.
64
65     IO_error is used in the same way as C++ standard library
66     exceptions.
67  */
68  class IO_error : public std::runtime_error
69  {
70  public:
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.