libfswatch  1.9.3
libfswatch_exception.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015 Enrico M. Crisostomo
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 3, or (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU General Public License along with
14  * this program. If not, see <http://www.gnu.org/licenses/>.
15  */
26 #ifndef LIBFSW_EXCEPTION_H
27 # define LIBFSW_EXCEPTION_H
28 
29 # include "../c/error.h"
30 # include <exception>
31 # include <string>
32 
33 namespace fsw
34 {
41  class libfsw_exception : public std::exception
42  {
43  public:
51  libfsw_exception(std::string cause, int code = FSW_ERR_UNKNOWN_ERROR);
52 
58  virtual const char *what() const noexcept;
59 
65  virtual int error_code() const noexcept;
66 
70  virtual ~libfsw_exception() noexcept;
71 
75  explicit operator int() const noexcept;
76 
77  private:
78  const std::string cause;
79  const int code;
80  };
81 }
82 
83 #endif /* LIBFSW_EXCEPTION_H */
Main namespace of libfswatch.
Definition: event.cpp:23
libfsw_exception(std::string cause, int code=FSW_ERR_UNKNOWN_ERROR)
Constructs an exception with the specified cause and error code.
Definition: libfswatch_exception.cpp:23
Base exception of the libfswatch library.
Definition: libfswatch_exception.hpp:41
virtual ~libfsw_exception() noexcept
Destructs an instance of this class.
Definition: libfswatch_exception.cpp:43
virtual int error_code() const noexcept
Gets the error code.
Definition: libfswatch_exception.cpp:33
virtual const char * what() const noexcept
Gets the error message.
Definition: libfswatch_exception.cpp:28
#define FSW_ERR_UNKNOWN_ERROR
Definition: error.h:37