struct
TResult
template<typename T>Helper type to be used as a return value from methods/functions.
Contains success/failure state, along with an optional error message in the failure case, or an output object in case of success.
Public
Constructors
Methods
IsSuccessful
bool IsSuccessful() const
Returns true if the result is one of the success states.
GetFullErrorMessage
String GetFullErrorMessage() const
Returns error message and additional error message as a combined string.
staticSuccess
Creates the success result object.
- output
- Object to return from the function/method.
- status
- One of the successful result status code.
Returns: Newly created TResult object.
staticSuccess
Creates the success result object.
- output
- Object to return from the function/method.
- status
- One of the successful result status code.
Returns: Newly created TResult object.
staticFail
static TResult<T> Fail(const char *errorMessage, ResultStatus status = ResultStatus::Failed, const String &additionalErrorMessage = StringUtility::kBlank)
Creates the fail result object.
- errorMessage
- Error message describing the failure.
- status
- One of the failure result status code.
- additionalErrorMessage
- Additional error message for information that cannot easily be stored in .
Returns: Newly created TResult object.
staticFail
static TResult<T> Fail(const char *errorMessage, Result &&childResult, const String &additionalErrorMessage = StringUtility::kBlank)
Creates the fail result object by inheriting the status from another result object.
Other result object error message is appended in the additional error message.
- errorMessage
- Error message describing the failure.
- childResult
- Result from which to inherit the failure status and append the error message.
- additionalErrorMessage
- Additional error message for information that cannot easily be stored in . The other result's error message will be appended to this error message.
Returns: Newly created TResult object.
Fields
Status
ResultStatus Status
ErrorMessage
const char * ErrorMessage
AdditionalErrorMessage
String AdditionalErrorMessage
Output
T Output
Private
Constructors
TResult<T>
TResult<T>(ResultStatus status, const char *errorMessage, String additionalErrorMessage = StringUtility::kBlank)
TResult<T>
TResult<T>
TResult<T>(ResultStatus status, T &&output)