nn::Result Classclass Result
Class that indicates the result of an operation.
The SDK interface will return an instance of the nn:Result class when it is possible to return an error.
For the handling of the Result returned by the different libraries, see the manuals for the respective libraries and APIs. We will give a general description of Result handling here.
The 32 bits of Result are divided into four sections: LEVEL, SUMMARY, MODULE, and DESCRIPTION.
The internal values of Result are used at debugging to determine the cause of an error.
LEVEL indicates the error processing policy. See nn::Result::Level for the meaning of the values.
SUMMARY indicates a summary of the error and MODULE indicates the module where error occurred. DESCRIPTION indicates the details of the error.
The application in principle does not branch processing on individual values such as those in DESCRIPTION. Instead it processes errors by comparing the overall 32 bit value. Each library defines the 32 bit Result values that the application needs to process.
The following gives an example of error handling using the nn::uds library.
nn::Result result = nn::uds::CTR::EjectClient();
if( result.IsFailure() )
{
if( result == nn::uds::ResultNotInitialized() )
{
// Not initialized.
}
else if( result == nn::uds::ResultInvalidState() )
{
// Request cannot be executed in the current system state.
}
else if( result == nn::uds::ResultWirelessOff() )
{
// Wireless OFF mode.
}
else
{
// Some other error has occurred.
}
}
As shown above, first determine from the result if the operation succeeded or failed, and if it failed, match against the results defined by the libraries to identify the error details.
Take note of the following points.
It is possible that a system update leads to result values that were not defined when an application was developed. In such cases, you can call the nn::Result::IsSuccess and nn::Result::IsFailure functions to determine if a process succeeded or failed.
Nintendo recommends not matching result values without checking for success, as this entails the risk of falsely determining success in cases of unexpected errors.
Some result codes may have identical values but different names in multiple libraries. Note that there may be cases where applications cannot handle unexpected errors, and the namespace must be explicitly specified.
fs Library Handling The fs library includes a very large number of potential error types. Due to the risk that the above matching approach might fail to identify an error, fs library errors are handled differently. See the nn::fs library reference materials for details.
Level
|
Enumerated type that indicates the severity of errors. (Do not use this type for error handling.) | |
|---|---|---|
| Summary | Enumerated type that indicates the summary of an error. (Do not use this type for error handling.) | |
| Module | Enumerated type that indicates the modules in which errors occurred. (Do not use this type for error handling.) | |
Description
|
Enumerated type representing error descriptions. (Do not use this type for error handling.) |
| Determination | ||
|---|---|---|
IsFailure
|
Returns true if the operation failed, or false if it succeeded. |
|
IsSuccess
|
Returns true if the operation succeeded, or false if it failed. |
|
operator ==
|
Tests for equality. | |
operator !=
|
Tests for inequality. | |
| Development support. | ||
GetPrintableBits
|
Converts a Result into a 32-bit array. |
|
CONFIDENTIAL