mn_lock_exptions.hpp
Go to the documentation of this file.
1 /*
2 *This file is part of the Mini Thread Library (https://github.com/RoseLeBlood/MiniThread ).
3 *Copyright (c) 2020 Amber-Sophia Schroeck
4 *
5 *The Mini Thread Library is free software; you can redistribute it and/or modify
6 *it under the terms of the GNU Lesser General Public License as published by
7 *the Free Software Foundation, version 3, or (at your option) any later version.
8 
9 *The Mini Thread Library is distributed in the hope that it will be useful, but
10 *WITHOUT ANY WARRANTY; without even the implied warranty of
11 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 *General Public License for more details.
13 *
14 *You should have received a copy of the GNU Lesser General Public
15 *License along with the Mini Thread Library; if not, see
16 *<https://www.gnu.org/licenses/>.
17 */
18 #ifndef MINLIB_ESP32_LOCK_EXCEPTION_
19 #define MINLIB_ESP32_LOCK_EXCEPTION_
20 
21 #include "../mn_config.hpp"
22 
23 #include <exception>
24 
25 #if MN_THREAD_CONFIG_USE_EXCEPTIONS == MN_THREAD_CONFIG_YES
26  #if MN_THREAD_CONFIG_DEBUG == MN_THREAD_CONFIG_YES
30  #define MN_THROW_LOCK_EXP(CODE) throw mn::error::lockcreate_exception(CODE, __LINE__, __FILE__);
31  #define MN_THROW_LOCK_EXP2(CODE, RET) throw mn::error::lockcreate_exception(CODE, __LINE__, __FILE__);
32  #else
36  #define MN_THROW_LOCK_EXP(CODE) throw lockcreate_exception(CODE);
37  #define MN_THROW_LOCK_EXP2(CODE, RET) throw lockcreate_exception(CODE);
38  #endif // MN_THREAD_CONFIG_DEBUG
39 #else
43  #define MN_THROW_LOCK_EXP(CODE) set_error(CODE);
47  #define MN_THROW_LOCK_EXP2(CODE, RET) { set_error(CODE); return RET; }
48 #endif //MN_THREAD_CONFIG_USE_EXCEPTIONS
49 
50 #if MN_THREAD_CONFIG_USE_EXCEPTIONS == MN_THREAD_CONFIG_YES
51 namespace mn {
52  namespace error {
58  class lockcreate_exception : public std::exception {
59  public:
65  lockcreate_exception(int code);
73  lockcreate_exception(int code, int line, const char* file);
74 
82  virtual const char* what();
83  private:
84  int m_iCode;
85  int m_iLine;
86  const char* m_strFile;
87  };
88  }
89 }
90 #endif // MN_THREAD_CONFIG_USE_EXCEPTIONS
91 
92 #endif //MINLIB_ESP32_LOCK_EXCEPTION_
Definition: mn_allocator_typetraits.hpp:25