2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief Exception inline non-template implementation */
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::ExceptionMixin
27 prefix_ senf::ExceptionMixin::ExceptionMixin(std::string const & description)
35 prefix_ std::string senf::ExceptionMixin::message()
39 return what_.substr(excLen_);
45 prefix_ std::string senf::ExceptionMixin::backtrace()
49 return what_.substr(0,excLen_-4);
55 prefix_ void senf::ExceptionMixin::append(std::string text)
60 //-/////////////////////////////////////////////////////////////////////////////////////////////////
63 prefix_ senf::Exception::Exception(std::string const & description)
64 : ExceptionMixin(description)
67 //-/////////////////////////////////////////////////////////////////////////////////////////////////
68 // senf::SystemException
70 prefix_ senf::SystemException::SystemException(std::string const & descr _SENF_EXC_DEBUG_ARGS_ND)
72 init(descr, errno _SENF_EXC_DEBUG_ARGS_P);
75 prefix_ senf::SystemException::SystemException(int code _SENF_EXC_DEBUG_ARGS_ND)
77 init("", code _SENF_EXC_DEBUG_ARGS_P);
80 prefix_ senf::SystemException::SystemException(std::string const & descr, int code
81 _SENF_EXC_DEBUG_ARGS_ND)
83 init(descr, code _SENF_EXC_DEBUG_ARGS_P);
86 prefix_ int senf::SystemException::errorNumber()
92 prefix_ char const * senf::SystemException::errorString()
95 return std::strerror(code_);
98 prefix_ bool senf::SystemException::anyOf(int c0, int c1, int c2, int c3, int c4, int c5,
99 int c6, int c7, int c8, int c9)
103 (c0 && code_ == c0) ||
104 (c1 && code_ == c1) ||
105 (c2 && code_ == c2) ||
106 (c3 && code_ == c3) ||
107 (c4 && code_ == c4) ||
108 (c5 && code_ == c5) ||
109 (c6 && code_ == c6) ||
110 (c7 && code_ == c7) ||
111 (c8 && code_ == c8) ||
115 prefix_ senf::SystemException::~SystemException()
119 //-/////////////////////////////////////////////////////////////////////////////////////////////////
120 // senf::InvalidArgumentException
122 prefix_ senf::InvalidArgumentException::InvalidArgumentException(std::string const & what_arg)
123 : WrapException<std::invalid_argument>(std::invalid_argument(what_arg))
126 //-/////////////////////////////////////////////////////////////////////////////////////////////////
133 // c-file-style: "senf"
134 // indent-tabs-mode: nil
135 // ispell-local-dictionary: "american"
136 // compile-command: "scons -u test"
137 // comment-column: 40