fswatch 1.17.1
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
33namespace 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
53 libfsw_exception( const libfsw_exception& other ) noexcept;
54
55 libfsw_exception& operator=(const libfsw_exception&) noexcept;
56
62 const char *what() const noexcept override;
63
69 virtual int error_code() const noexcept;
70
74 ~libfsw_exception() noexcept override;
75
79 explicit operator int() const noexcept;
80
81 private:
82 std::string cause;
83 int code;
84 };
85}
86
87#endif /* LIBFSW_EXCEPTION_H */
Base exception of the libfswatch library.
Definition: libfswatch_exception.hpp:42
virtual int error_code() const noexcept
Gets the error code.
Definition: libfswatch_exception.cpp:35
const char * what() const noexcept override
Gets the error message.
Definition: libfswatch_exception.cpp:30
libfsw_exception(std::string cause, int code=FSW_ERR_UNKNOWN_ERROR)
Constructs an exception with the specified cause and error code.
#define FSW_ERR_UNKNOWN_ERROR
Definition: error.h:37
Main namespace of libfswatch.
Definition: event.cpp:24