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

Last change on this file since 1178 was 1178, checked in by Peter, 14 years ago

fixes #344

  • 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 1178 2008-02-27 19:24:31Z peter $
5
6/*
7  Copyright (C) 2005, 2006 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2007 Jari Häkkinen
9
10  This file is part of the yat library, http://trac.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 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 used for error reported from Commandline or Option.
39   */
40  class cmd_error : public std::runtime_error
41  {
42  public:
43    inline cmd_error(std::string message)
44      : std::runtime_error(message) {}
45  };
46
47
48  /**
49     \brief Class for errors reported from underlying GSL calls.
50
51     GSL_error is used in the same way as C++ standard library
52     exceptions.
53  */
54  class GSL_error : public std::runtime_error
55  {
56  public:
57    /**
58       \brief Constructor to create an exception with a message.
59    */
60    inline GSL_error(std::string message) throw()
61      : std::runtime_error("GSL_error: " + message) {}
62
63    /**
64       \brief Constructor to create an exception with a message
65       containg the GSL error description.
66    */
67    inline GSL_error(std::string message, int gsl_status) throw()
68      : std::runtime_error("GSL_error: " + message + " " +
69                           gsl_strerror(gsl_status)) {}
70  };
71
72
73  /**
74     \brief Class to report errors associated with IO operations.
75
76     IO_error is used in the same way as C++ standard library
77     exceptions.
78  */
79  class IO_error : public std::runtime_error
80  {
81  public:
82    /**
83       \brief Constructor to create an exception with a message.
84    */
85    inline IO_error(std::string message) throw()
86      : std::runtime_error("IO_error: " + message) {}
87  };
88
89}}} // of namespace utility, yat, and theplu
90
91#endif
Note: See TracBrowser for help on using the repository browser.