21 lines
1.3 KiB
Markdown
21 lines
1.3 KiB
Markdown
# Return status
|
|
|
|
## Introduction
|
|
|
|
The vast majority of functions in Shelter return status code know as the `SH_STATUS` type. All the status codes are defined inside `shelter/lib/include/std/status.h`.
|
|
|
|
## Overview
|
|
|
|
Shelter define a status code with the `SH_STATUS` type. It's a wrapper of `sh_int64`.
|
|
|
|
The sign of a status play a big role:
|
|
- If the sign is negative, the status code isn't an error but rather an indication of something not that bad that happened during the function call. It can also serve the purpose of indicating a more detailled result.
|
|
- If the status code is 0, it's equivalent to a success, defined as `SH_STATUS_SUCCESS`
|
|
- If the sign is positive, the status code signify an error. You can use the `sh_status_error(SH_STATUS status)` function to know if a status code is an error. Return `SH_TRUE` if so.
|
|
|
|
Please check `shelter/lib/include/std/status.h` for the list of all status codes.
|
|
|
|
In Shelter, most function will returned to the caller the status code of all the functions calls they made if an error happened. Sometimes, it's necessary to dig through the code to understand from where an error come from.
|
|
|
|
If at any moment, a function that return a `SH_STATUS` call a function that return a pointer and the pointer is `SH_NULLPTR`, the status code `SH_STATUS_ERROR_NULLPTR_RETURNED` (not all error start with `SH_STATUS_ERROR`) will be returned.
|