mirror of
https://gitlab.com/niansa/libjustlm.git
synced 2025-03-06 20:49:17 +01:00
Improve some error handling macros
This commit is contained in:
parent
24849804b6
commit
94953cd174
4 changed files with 9 additions and 5 deletions
|
@ -29,7 +29,9 @@
|
|||
# define LM_ERRBOOL bool
|
||||
# define LM_BOOL_ERROR false
|
||||
# define LM_BOOL_SUCCESS true
|
||||
# define LM_ERROR_FORWARD(x) {auto v = x; if (!v) LM_CORETURN x;} 0
|
||||
# define LM_RETHROW(x) LM_CORETURN x;
|
||||
# define LM_ERROR_CATCH(x, errval, ...) {auto v = x; if (v == (errval)) __VA_ARGS__}
|
||||
# define LM_ERROR_FORWARD(x, errval) {auto v = x; if (v == (errval)) LM_CORETURN x;} 0
|
||||
#else
|
||||
# define LM_NOEXCEPTDECL
|
||||
# define LM_THROW(t, r) throw Exception(t)
|
||||
|
@ -39,7 +41,9 @@
|
|||
# define LM_ERRBOOL void
|
||||
# define LM_BOOL_ERROR
|
||||
# define LM_BOOL_SUCCESS
|
||||
# define LM_ERROR_FORWARD(x) {x;}
|
||||
# define LM_RETHROW(x) std::rethrow_exception(std::current_exception())
|
||||
# define LM_ERROR_CATCH(x, errval, ...) try {x;} catch (...) __VA_ARGS__
|
||||
# define LM_ERROR_FORWARD(x, errval) {x;}
|
||||
#endif
|
||||
|
||||
#ifdef LM_COSCHED
|
||||
|
|
|
@ -81,7 +81,7 @@ class GPTJInference final : public Inference {
|
|||
state->tokens.resize(params.n_ctx_window_top_bar);
|
||||
}
|
||||
// Evaluate tokens
|
||||
LM_ERROR_FORWARD(LM_COAWAIT evaluate_tokens(0, on_scroll));
|
||||
LM_ERROR_FORWARD(LM_COAWAIT evaluate_tokens(0, on_scroll), LM_BOOL_ERROR);
|
||||
LM_CORETURN true;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ class LLaMAInference final : public Inference {
|
|||
state->tokens.resize(params.n_ctx_window_top_bar);
|
||||
}
|
||||
// Evaluate tokens
|
||||
LM_ERROR_FORWARD(LM_COAWAIT evaluate_tokens(0, on_scroll));
|
||||
LM_ERROR_FORWARD(LM_COAWAIT evaluate_tokens(0, on_scroll), LM_BOOL_ERROR);
|
||||
LM_CORETURN true;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class MPTInference final : public Inference {
|
|||
state->tokens.resize(params.n_ctx_window_top_bar);
|
||||
}
|
||||
// Evaluate tokens
|
||||
LM_ERROR_FORWARD(LM_COAWAIT evaluate_tokens(0, on_scroll));
|
||||
LM_ERROR_FORWARD(LM_COAWAIT evaluate_tokens(0, on_scroll), LM_BOOL_ERROR);
|
||||
LM_CORETURN true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue