Add a function to try to get a result or throw the error if there is one.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Madeorsk 2023-07-15 14:42:33 +02:00
parent 02c72c21fe
commit e81c5e2690
1 changed files with 10 additions and 0 deletions

View File

@ -132,6 +132,16 @@ typedef struct {
if (!ksresult_check(__ksresult_cache__)) return __ksresult_cache__; \
varname = ((result_type) __ksresult_cache__.result); \
}
/**
* Try to get a result and put it in the variable called varname.
* You must specify the type of the result you want to get.
* If there is an error, it is thrown directly. You cannot use this function if your function does not return a ksrerror.
*/
#define ksresult_get_throwerr(varname, result_type, _result) NULL; { \
ksresult __ksresult_cache__ = (_result); \
if (!ksresult_check(__ksresult_cache__)) return __ksresult_cache__.error; \
varname = ((result_type) __ksresult_cache__.result); \
}
/**
* Try to get a result while ignoring the error if there is one.
* You must specify the type of the result you want to get.