core: error: add function to test if an error has a particular vendor/code
This commit is contained in:
14
core/error.c
14
core/error.c
@@ -38,6 +38,20 @@ static void error_cleanup(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool b_result_is(
|
||||||
|
struct b_error *err, const b_error_vendor *vendor, b_error_status_code code)
|
||||||
|
{
|
||||||
|
if (!err) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (err->err_vendor != vendor) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return err->err_code == code;
|
||||||
|
}
|
||||||
|
|
||||||
const struct b_error_vendor *b_error_vendor_get_builtin(void)
|
const struct b_error_vendor *b_error_vendor_get_builtin(void)
|
||||||
{
|
{
|
||||||
return &builtin_vendor;
|
return &builtin_vendor;
|
||||||
|
|||||||
@@ -330,6 +330,9 @@ BLUE_API b_error *z__b_error_caused_by(b_error *, b_error *);
|
|||||||
BLUE_API b_error *z__b_error_caused_by_b_status(b_error *, b_status);
|
BLUE_API b_error *z__b_error_caused_by_b_status(b_error *, b_status);
|
||||||
BLUE_API void z__b_error_throw(b_error *, const char *, unsigned int, const char *);
|
BLUE_API void z__b_error_throw(b_error *, const char *, unsigned int, const char *);
|
||||||
|
|
||||||
|
BLUE_API bool b_result_is(
|
||||||
|
b_result result, const b_error_vendor *vendor, b_error_status_code code);
|
||||||
|
|
||||||
BLUE_API const b_error_vendor *b_error_vendor_get_builtin(void);
|
BLUE_API const b_error_vendor *b_error_vendor_get_builtin(void);
|
||||||
BLUE_API const b_error_vendor *b_error_vendor_get_errno(void);
|
BLUE_API const b_error_vendor *b_error_vendor_get_errno(void);
|
||||||
BLUE_API const b_error_definition *b_error_vendor_get_error_definition(
|
BLUE_API const b_error_definition *b_error_vendor_get_error_definition(
|
||||||
|
|||||||
Reference in New Issue
Block a user