| 156 | |
| 157 | == Argument Checking and Validation == |
| 158 | |
| 159 | Where possible, avoid doing your own argument checking/validation and manually throwing exceptions for invalid method arguments and use one of the available macros to do this for you in {{{Foundation\System\Util.h}}} |
| 160 | |
| 161 | {{{ |
| 162 | CHECKNULL(pointer, methodname) //Check that pointer is not null. Throws MgNullReferenceException if null |
| 163 | CHECKARGUMENTNULL(pointer, methodname) //Check that pointer is not null. Throws MgNullArgumentException if null |
| 164 | CHECKARGUMENTEMPTYSTRING(stlstring, methodname) //Check that given std::basic_string<T> is not empty. Throws MgInvalidArgumentException if empty |
| 165 | MG_CHECK_RANGE(value, min, max, methodname) //Check that given argument is within the specified range. Throws MgNullReferenceException if null |
| 166 | }}} |
| 167 | |
| 168 | These macros will not only do the requisite checks, but also capture the name of the offending argument and use the correct error message |