mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-25 10:52:48 -06:00
result: Add default error code for the ResultCode(-1) case
Will be used to reduce the overall duplication of the same magic value all over the codebase in following changes.
This commit is contained in:
parent
581d2e36e5
commit
ef060ed40c
1 changed files with 9 additions and 1 deletions
|
@ -146,6 +146,14 @@ constexpr bool operator!=(const ResultCode& a, const ResultCode& b) {
|
||||||
/// The default success `ResultCode`.
|
/// The default success `ResultCode`.
|
||||||
constexpr ResultCode RESULT_SUCCESS(0);
|
constexpr ResultCode RESULT_SUCCESS(0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Placeholder result code used for unknown error codes.
|
||||||
|
*
|
||||||
|
* @note This should only be used when a particular error code
|
||||||
|
* is not known yet.
|
||||||
|
*/
|
||||||
|
constexpr ResultCode RESULT_UNKNOWN(UINT32_MAX);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an optional value type. It holds a `ResultCode` and, if that code is a success code,
|
* This is an optional value type. It holds a `ResultCode` and, if that code is a success code,
|
||||||
* also holds a result of type `T`. If the code is an error code then trying to access the inner
|
* also holds a result of type `T`. If the code is an error code then trying to access the inner
|
||||||
|
@ -183,7 +191,7 @@ class ResultVal {
|
||||||
public:
|
public:
|
||||||
/// Constructs an empty `ResultVal` with the given error code. The code must not be a success
|
/// Constructs an empty `ResultVal` with the given error code. The code must not be a success
|
||||||
/// code.
|
/// code.
|
||||||
ResultVal(ResultCode error_code = ResultCode(UINT32_MAX)) : result_code(error_code) {
|
ResultVal(ResultCode error_code = RESULT_UNKNOWN) : result_code(error_code) {
|
||||||
ASSERT(error_code.IsError());
|
ASSERT(error_code.IsError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue