diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-08-11 18:43:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-11 18:43:27 +0200 |
commit | d7a39cc3461a2bbcf7a38cce1be046c3427e1bf8 (patch) | |
tree | 39cc3ff8a9ff5682fe416e025841dc9cabf04692 /core/variant | |
parent | 1d7a358588dd61836480cd5c1f6da549c7853cf9 (diff) | |
parent | 054d8852b9668ee5b105df90d63ab70cb1c91fc7 (diff) |
Merge pull request #38992 from Dragoncraft89/master
Error handling functions for GdScript
Diffstat (limited to 'core/variant')
-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 34dbf130b6..6c57d1de10 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); |