diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-10-05 20:49:35 +0200 |
---|---|---|
committer | golfinq <golfinqz@gmail.com> | 2023-10-02 14:23:11 -0400 |
commit | 5efbed51cce62cdd9a2927638030e76bf688cdf7 (patch) | |
tree | 1880ba45a1dce852ded71b665567d0382af5b933 /core/variant/variant.h | |
parent | 0ca8542329888e8dccba89d59d3b728090c29991 (diff) | |
download | redot-engine-5efbed51cce62cdd9a2927638030e76bf688cdf7.tar.gz |
GDScript: Improve error messages for invalid indexing
These errors are very common when using an invalid property name
or calling on an object of the wrong type, and the previous message
was a bit cryptic for users.
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Co-authored-by: golfinq <golfinqz@gmail.com>
Diffstat (limited to 'core/variant/variant.h')
-rw-r--r-- | core/variant/variant.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/core/variant/variant.h b/core/variant/variant.h index d698f85754..190f4e130d 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -703,9 +703,20 @@ public: bool has_key(const Variant &p_key, bool &r_valid) const; /* Generic */ - - void set(const Variant &p_index, const Variant &p_value, bool *r_valid = nullptr); - Variant get(const Variant &p_index, bool *r_valid = nullptr) const; + enum VariantSetError { + SET_OK, + SET_KEYED_ERR, + SET_NAMED_ERR, + SET_INDEXED_ERR + }; + enum VariantGetError { + GET_OK, + GET_KEYED_ERR, + GET_NAMED_ERR, + GET_INDEXED_ERR + }; + void set(const Variant &p_index, const Variant &p_value, bool *r_valid = nullptr, VariantSetError *err_code = nullptr); + Variant get(const Variant &p_index, bool *r_valid = nullptr, VariantGetError *err_code = nullptr) const; bool in(const Variant &p_index, bool *r_valid = nullptr) const; bool iter_init(Variant &r_iter, bool &r_valid) const; |