Difference between revisions of "Error Applet"

From Nintendo Switch Brew
Jump to navigation Jump to search
m (Fixed a typo)
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
This is the applet presented when a title displays an error message.
 
This is the applet presented when a title displays an error message.
See [[AM_services#Library_Applets]]. The error applet expects two [[AM_services#IStorage|IStorage]] inputs and no output.
+
See [[AM_services#Library_Applets]].
  
== ErrorConfig ==
+
All errors displayed by this applet get logged and can be viewed under 'Settings' > 'Support' > 'Error History'.
  
This has size 0x1018 and contains the error code, a short description of the error and a more detailed description of the error, displayed when the user clicks on "Details". Typically, all unused values can be set to zero. The first should be set to 1 if a custom error message is to be displayed. Otherwise, a default error message will be shown.
+
On pre-5.0.0 the specified LanguageCode has to be valid, otherwise a fatal-error is thrown. With [5.0.0+] it will use en-US when the LanguageCode is invalid.
  
The error code is stored at offsets 0x8, containing the first part of the code, and 0xC, containing the second part of the code. Those values are expected to be u64's.
+
== ErrorContext ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x1 || Type
 +
|-
 +
| 0x1 || 0x7 || Padding
 +
|-
 +
| 0x8 || 0x1F4 || Data
 +
|-
 +
| 0x1FC || 0x4 || Result
 +
|}
  
The short description of the error is stored as a char* at offset 0x18, the long description of the error is stored as a char* at offset 0x818.
+
This 0x200 bytes struct is used to set specific error contexts for [[Error_Report_services#SubmitContext|erpt:c]].
 +
 
 +
Depending on '''Type''', different error report fields will be attached and sent:
 +
* Type 0: Invalid (no fields are attached to the report);
 +
* Type 1: [[Error_Report_services#Fields|ServerFqdn]] and [[Error_Report_services#Fields|ServerIpAddress]];
 +
* Type 2: [[Error_Report_services#Fields|FileSystemPath]] and [[Error_Report_services#Fields|ResultBacktrace]];
 +
* Type 3: [[Error_Report_services#Fields|WebMediaPlayerOpenUrl]] and [[Error_Report_services#Fields|WebMediaPlayerLastSocketErrors]];
 +
* Type 4: [[Error_Report_services#Fields|LcsApplicationId]], [[Error_Report_services#Fields|LcsContentMetaKeyIdList]], [[Error_Report_services#Fields|LcsContentMetaKeyVersionList]], [[Error_Report_services#Fields|LcsContentMetaKeyTypeList]], [[Error_Report_services#Fields|LcsSenderFlag]], [[Error_Report_services#Fields|LcsApplicationRequestFlag]], [[Error_Report_services#Fields|LcsHasExFatDriverFlag]], [[Error_Report_services#Fields|LcsIpAddress]] and  [[Error_Report_services#Fields|ResultBacktrace]].
 +
 
 +
== ErrorCommonHeader ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x1 || u8 type
 +
|-
 +
| 0x1 || 0x1 || u8 jumpFlag. When clear, this indicates WithoutJump.
 +
|-
 +
| 0x2 || 0x3 || ?
 +
|-
 +
| 0x5 || 0x1 || u8 contextFlag. When set with type=0, indicates that an additional storage is pushed for [[#ResultBacktrace]]. [4.0.0+]: When set indicates that an additional storage is pushed for [[#ErrorContext]].
 +
|-
 +
| 0x6 || 0x1 || u8 resultFlag. [[#ErrorCommonArg]]: When clear, ErrorCode is used, otherwise the applet generates the error-code from res.
 +
|-
 +
| 0x7 || 0x1 || u8 contextFlag2. Similar to contextFlag except for [[#ErrorCommonArg]], indicating [[#ErrorContext]] is used.
 +
|}
 +
 
 +
== ErrorCommonArg ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x8 || ErrorCommonHeader
 +
|-
 +
| 0x8 || 0x8 || [[#ErrorCode]]
 +
|-
 +
| 0x10 || 0x4 || Result res
 +
|}
 +
 
 +
ShowError: type=0, jumpFlag={varies}, contextFlag2={set when ErrorContext used}.
 +
* If the input Result is 0xC8A2, the applet will display a special dialog regarding the current application requiring a software update, with buttons "Later" and "Restart". The official user-process name for this is <code>ShowUnacceptableApplicationVersionError</code>.
 +
* [3.0.0+] There's also special dialog handling for Result 0xCAA2. The official user-process name for this is <code>ShowUnacceptableAddOnContentVersionError</code>.
 +
 
 +
== ErrorPctlArg ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x8 || ErrorCommonHeader. type=4.
 +
|-
 +
| 0x8 || 0x4 || Result res
 +
|}
 +
 
 +
This struct is 0xC-bytes. Used instead of [[#ErrorCommonArg]] where a Result error would have been displayed with type=0, for module=PCTL errors with desc 100-119. For this the applet will display the following dialog (without report logging): "This software is restricted by Parental Controls".
 +
 
 +
== ErrorEulaData ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x20000 || data
 +
|}
 +
 
 +
== ErrorEulaArg ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x8 || ErrorCommonHeader. jumpFlag = 1.
 +
|-
 +
| 0x8 || 0x4 || [[Settings_services|RegionCode]]
 +
|}
 +
 
 +
This struct is 0xC-bytes.
 +
 
 +
* Eula: ErrorCommonHeader.type = 3. Displays the EULA.
 +
* SystemUpdateEula: ErrorCommonHeader.type = 8. Displays the system-update EULA. Uses an additional IStorage containing [[#ErrorEulaData]], from [[Applet_Manager_services#CreateTransferMemoryStorage]] with flag=false.
 +
 
 +
== ErrorRecordArg ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x8 || ErrorCommonHeader. type=5 and jumpFlag=1.
 +
|-
 +
| 0x8 || 0x8 || [[#ErrorCode]]
 +
|-
 +
| 0x10 || 0x8 || u64 POSIX timestamp
 +
|}
 +
 
 +
The applet does not log an error report for this. Used by [[qlaunch]] for viewing previously logged errors via the "View the Error" button.
 +
 
 +
== SystemErrorArg ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x8 || ErrorCommonHeader. type=1.
 +
|-
 +
| 0x8 || 0x8 || [[#ErrorCode]]
 +
|-
 +
| 0x10 || 0x8 || [[Settings_services|LanguageCode]]
 +
|-
 +
| 0x18 || 0x800 || UTF-8 string dialogMessage
 +
|-
 +
| 0x818 || 0x800 || UTF-8 string fullscreenMessage, displayed when the user clicks on "Details". When not set this disables displaying Details.
 +
|}
 +
 
 +
This struct is 0x1018-bytes.
 +
 
 +
== ApplicationErrorArg ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x8 || ErrorCommonHeader. type=2 and jumpFlag=1.
 +
|-
 +
| 0x8 || 0x4 || u32 errorNumber. Raw decimal error number which is displayed in the dialog.
 +
|-
 +
| 0xC || 0x8 || [[Settings_services|LanguageCode]]
 +
|-
 +
| 0x14 || 0x800 || UTF-8 string dialogMessage
 +
|-
 +
| 0x814 || 0x800 || UTF-8 string fullscreenMessage, displayed when the user clicks on "Details". When not set this disables displaying Details.
 +
|}
 +
 
 +
This struct is 0x1014-bytes.
 +
 
 +
== ErrorCode ==
 +
This is an u64 containing the [[Error_codes|error-code]]: the low u32 is the module portion which is normally set to <code>module + 2000</code>, and the high u32 is the error description.
 +
 
 +
== ResultBacktrace ==
 +
{| class="wikitable" border="1"
 +
|-
 +
! Offset || Size || Description
 +
|-
 +
| 0x0 || 0x4 || s32 total entries
 +
|-
 +
| 0x4 || 0x4*total_entries || Array of Result
 +
|}
  
 
== Usage ==  
 
== Usage ==  
User-processes should push a common arguments struct as well as the typical ErrorConfig struct. Since the error applet doesn't have any output, user-processes can then directly join the applet and wait for it to finish.
+
User-processes should push a common arguments struct (version=0) as well as the Arg struct. Once the applet finishes running successfully, it may return an output storage in some cases. An u8 status value is located at +1, where non-zero indicates error.
  
 
[[Category:Library Applets]]
 
[[Category:Library Applets]]

Revision as of 20:14, 29 March 2019

This is the applet presented when a title displays an error message. See AM_services#Library_Applets.

All errors displayed by this applet get logged and can be viewed under 'Settings' > 'Support' > 'Error History'.

On pre-5.0.0 the specified LanguageCode has to be valid, otherwise a fatal-error is thrown. With [5.0.0+] it will use en-US when the LanguageCode is invalid.

ErrorContext

Offset Size Description
0x0 0x1 Type
0x1 0x7 Padding
0x8 0x1F4 Data
0x1FC 0x4 Result

This 0x200 bytes struct is used to set specific error contexts for erpt:c.

Depending on Type, different error report fields will be attached and sent:

ErrorCommonHeader

Offset Size Description
0x0 0x1 u8 type
0x1 0x1 u8 jumpFlag. When clear, this indicates WithoutJump.
0x2 0x3 ?
0x5 0x1 u8 contextFlag. When set with type=0, indicates that an additional storage is pushed for #ResultBacktrace. [4.0.0+]: When set indicates that an additional storage is pushed for #ErrorContext.
0x6 0x1 u8 resultFlag. #ErrorCommonArg: When clear, ErrorCode is used, otherwise the applet generates the error-code from res.
0x7 0x1 u8 contextFlag2. Similar to contextFlag except for #ErrorCommonArg, indicating #ErrorContext is used.

ErrorCommonArg

Offset Size Description
0x0 0x8 ErrorCommonHeader
0x8 0x8 #ErrorCode
0x10 0x4 Result res

ShowError: type=0, jumpFlag={varies}, contextFlag2={set when ErrorContext used}.

  • If the input Result is 0xC8A2, the applet will display a special dialog regarding the current application requiring a software update, with buttons "Later" and "Restart". The official user-process name for this is ShowUnacceptableApplicationVersionError.
  • [3.0.0+] There's also special dialog handling for Result 0xCAA2. The official user-process name for this is ShowUnacceptableAddOnContentVersionError.

ErrorPctlArg

Offset Size Description
0x0 0x8 ErrorCommonHeader. type=4.
0x8 0x4 Result res

This struct is 0xC-bytes. Used instead of #ErrorCommonArg where a Result error would have been displayed with type=0, for module=PCTL errors with desc 100-119. For this the applet will display the following dialog (without report logging): "This software is restricted by Parental Controls".

ErrorEulaData

Offset Size Description
0x0 0x20000 data

ErrorEulaArg

Offset Size Description
0x0 0x8 ErrorCommonHeader. jumpFlag = 1.
0x8 0x4 RegionCode

This struct is 0xC-bytes.

ErrorRecordArg

Offset Size Description
0x0 0x8 ErrorCommonHeader. type=5 and jumpFlag=1.
0x8 0x8 #ErrorCode
0x10 0x8 u64 POSIX timestamp

The applet does not log an error report for this. Used by qlaunch for viewing previously logged errors via the "View the Error" button.

SystemErrorArg

Offset Size Description
0x0 0x8 ErrorCommonHeader. type=1.
0x8 0x8 #ErrorCode
0x10 0x8 LanguageCode
0x18 0x800 UTF-8 string dialogMessage
0x818 0x800 UTF-8 string fullscreenMessage, displayed when the user clicks on "Details". When not set this disables displaying Details.

This struct is 0x1018-bytes.

ApplicationErrorArg

Offset Size Description
0x0 0x8 ErrorCommonHeader. type=2 and jumpFlag=1.
0x8 0x4 u32 errorNumber. Raw decimal error number which is displayed in the dialog.
0xC 0x8 LanguageCode
0x14 0x800 UTF-8 string dialogMessage
0x814 0x800 UTF-8 string fullscreenMessage, displayed when the user clicks on "Details". When not set this disables displaying Details.

This struct is 0x1014-bytes.

ErrorCode

This is an u64 containing the error-code: the low u32 is the module portion which is normally set to module + 2000, and the high u32 is the error description.

ResultBacktrace

Offset Size Description
0x0 0x4 s32 total entries
0x4 0x4*total_entries Array of Result

Usage

User-processes should push a common arguments struct (version=0) as well as the Arg struct. Once the applet finishes running successfully, it may return an output storage in some cases. An u8 status value is located at +1, where non-zero indicates error.