root/tls/error_category.hh
| Revision b8875c20a53bf3aaf496d59b929f060e136f1977, 2.0 KB (checked in by Antti-Juhani Kaijanaho <antti-juhani@…>, 3 years ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | /* This file is part of Alue, the multiprotocol Internet discussion daemon |
| 2 | |
| 3 | Copyright © 2009 Antti-Juhani Kaijanaho |
| 4 | |
| 5 | Alue is free software: you can redistribute it and/or modify it |
| 6 | under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation, either version 3 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | Alue is distributed in the hope that it will be useful, but |
| 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with Alue. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | */ |
| 19 | |
| 20 | #ifndef GUARD_ERROR_CATEGORY_HH |
| 21 | #define GUARD_ERROR_CATEGORY_HH |
| 22 | |
| 23 | #include <gnutls/gnutls.h> |
| 24 | |
| 25 | #include <boost/system/error_code.hpp> |
| 26 | #include <boost/system/system_error.hpp> |
| 27 | #include <string> |
| 28 | |
| 29 | |
| 30 | |
| 31 | namespace tls |
| 32 | { |
| 33 | class error_category : public boost::system::error_category |
| 34 | { |
| 35 | public: |
| 36 | ~error_category() {} |
| 37 | |
| 38 | const char *name() const { return "TLS error"; } |
| 39 | std::string message(int ev) const { |
| 40 | return gnutls_strerror(ev); |
| 41 | } |
| 42 | |
| 43 | static error_category *instance() { |
| 44 | static error_category ecat; |
| 45 | return &ecat; |
| 46 | } |
| 47 | static boost::system::error_condition cond(int v) { |
| 48 | return boost::system::error_condition(v, *instance()); |
| 49 | } |
| 50 | static boost::system::error_code code(int v) { |
| 51 | return boost::system::error_code(v, *instance()); |
| 52 | } |
| 53 | static boost::system::system_error exc(int v, std::string w) { |
| 54 | return boost::system::system_error(code(v), w); |
| 55 | } |
| 56 | }; |
| 57 | } |
| 58 | |
| 59 | #endif /* GUARD_ERROR_CATEGORY_HH */ |
Note: See TracBrowser
for help on using the browser.
