Except.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * Except.h
8  *
9  * @author: Dec 2021 - Mikee47 <mike@sillyhouse.net>
10  *
11  */
12 
13 #include "Types.h"
14 #include <csetjmp>
15 
16 namespace Jerryscript
17 {
18 enum class FatalCode {
19 #define XX(jt, t) t = jt,
20  JERRY_FATAL_CODE_MAP(XX)
21 #undef XX
22 };
23 
24 class Except
25 {
26 public:
27  Except() : prev(current)
28  {
29  current = this;
30  }
31 
33  {
34  current = prev;
35  }
36 
37  [[noreturn]] static void raise(jerry_fatal_code_t code);
38 
40  {
41  return mCode;
42  }
43 
44  operator String() const;
45 
46  std::jmp_buf context;
47 
48 private:
49  static Except* current;
50  Except* prev;
51  FatalCode mCode{};
52 };
53 
54 #define JS_TRY() \
55  ::Jerryscript::Except e; \
56  if(setjmp(e.context) == 0)
57 #define JS_CATCH() else
58 
59 } // namespace Jerryscript
60 
String toString(Jerryscript::FatalCode code)
Definition: Except.h:25
FatalCode code()
Definition: Except.h:39
~Except()
Definition: Except.h:32
Except()
Definition: Except.h:27
std::jmp_buf context
Definition: Except.h:46
The String class.
Definition: WString.h:137
Definition: Libraries/jerryscript/src/include/Jerryscript/Context.h:124
FatalCode
Definition: Except.h:18