diff options
author | Florian Kothmeier <floriankothmeier@web.de> | 2020-05-23 22:38:48 +0200 |
---|---|---|
committer | Florian Kothmeier <floriankothmeier@web.de> | 2021-04-27 22:02:35 +0200 |
commit | 054d8852b9668ee5b105df90d63ab70cb1c91fc7 (patch) | |
tree | ae05c98d5b4c2b7596a2615f633c72b22638834b /core/variant/variant_utility.cpp | |
parent | 0582cefcbb6c4dc0f5d36000f39c627ecf5f9b70 (diff) |
Add error_string function
Diffstat (limited to 'core/variant/variant_utility.cpp')
-rw-r--r-- | core/variant/variant_utility.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/variant/variant_utility.cpp b/core/variant/variant_utility.cpp index f154ab1ed6..7cad04f10b 100644 --- a/core/variant/variant_utility.cpp +++ b/core/variant/variant_utility.cpp @@ -484,6 +484,14 @@ struct VariantUtilityFunctions { return str; } + static inline String error_string(Error error) { + if (error < 0 || error >= ERR_MAX) { + return String("(invalid error code)"); + } + + return String(error_names[error]); + } + static inline void print(const Variant **p_args, int p_arg_count, Callable::CallError &r_error) { if (p_arg_count < 1) { r_error.error = Callable::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS; @@ -1234,6 +1242,7 @@ void Variant::_register_variant_utility_functions() { FUNCBINDVR(weakref, sarray("obj"), Variant::UTILITY_FUNC_TYPE_GENERAL); FUNCBINDR(_typeof, sarray("variable"), Variant::UTILITY_FUNC_TYPE_GENERAL); FUNCBINDVARARGS(str, sarray(), Variant::UTILITY_FUNC_TYPE_GENERAL); + FUNCBINDR(error_string, sarray("error"), Variant::UTILITY_FUNC_TYPE_GENERAL); FUNCBINDVARARGV(print, sarray(), Variant::UTILITY_FUNC_TYPE_GENERAL); FUNCBINDVARARGV(printerr, sarray(), Variant::UTILITY_FUNC_TYPE_GENERAL); FUNCBINDVARARGV(printt, sarray(), Variant::UTILITY_FUNC_TYPE_GENERAL); |