nn::Result Class

Header file: nn/Result.h

Syntax

class Result

Description

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 Meaning of Values Held by Result

The 32 bits of Result are divided into four sections: LEVEL, SUMMARY, MODULE, and DESCRIPTION.

The internal values of Result are used when 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.

Error Handling Example

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.

Identifying the Error Type when Processing Has Failed

It is possible system updates could define additional 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.

Explicitly Specifying Namespaces

Some result codes are defined with the same names but different values in different libraries. Always specify the namespace explicitly so that your application will not mishandle unexpected errors.

fs Library Handling

The fs library includes a very large number of error types. Due to the risk that the above matching approach might fail to identify an error, fs library errors are handled in special way. See the nn::fs library reference materials for details.

Enumerated Types

Level Enumerated type that indicates the severity of errors. (Do not use this type for error handling.)
Summary Enumerated type that provides a brief description of the 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 that describes the error in detail. (Do not use this type for error handling.)

Member Functions

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.

Revision History

2010/11/10
Added description of error handling.
2010/10/27
Added description of result value handling.
2010/01/07
Initial version.

CONFIDENTIAL