mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Make error handling more convenient
By adding some PRAY_* macros that encapsulate both the check and the returning of a null reference (UB). Plus transient avoidance of the flood of warnings emitted by Clang when checking 'this' for NULL. Plus explanation about the do-while(0) loop in some error macros.
This commit is contained in:
parent
21bf3778d5
commit
e9b7640f84
8 changed files with 66 additions and 34 deletions
|
|
@ -599,9 +599,9 @@ public:
|
|||
|
||||
const V &operator[](const K &p_key) const {
|
||||
|
||||
ERR_FAIL_COND_V(!_data._root, *(V *)NULL); // crash on purpose
|
||||
PRAY_COND(!_data._root, V);
|
||||
const Element *e = find(p_key);
|
||||
ERR_FAIL_COND_V(!e, *(V *)NULL); // crash on purpose
|
||||
PRAY_COND(!e, V);
|
||||
return e->_value;
|
||||
}
|
||||
V &operator[](const K &p_key) {
|
||||
|
|
@ -613,7 +613,7 @@ public:
|
|||
if (!e)
|
||||
e = insert(p_key, V());
|
||||
|
||||
ERR_FAIL_COND_V(!e, *(V *)NULL); // crash on purpose
|
||||
PRAY_COND(!e, V);
|
||||
return e->_value;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue