Repository navigation
err: Add err headers
#23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,40 @@ | ||
| #pragma once | ||
|
|
||
| #include <nn/err/err_ApplicationErrorArg.h> | ||
| #include <nn/err/err_ErrorCode.h> | ||
| #include <nn/err/err_ErrorMessageDatabaseVersion.h> | ||
| #include <nn/err/err_ErrorResultVariant.h> | ||
| #include <nn/err/err_ResultBacktrace.h> | ||
| #include <nn/err/err_SystemErrorArg.h> | ||
| #include <nn/nn_Result.h> | ||
| #include <nn/settings.h> | ||
| #include <nn/time.h> | ||
|
|
||
| namespace nn::err { | ||
| enum ErrorCodeCategoryType : uint32_t { | ||
| unk1, | ||
| unk2, | ||
| }; | ||
| class EulaData; // TODO | ||
| class ErrorViewerJumpDestination {}; // TODO | ||
|
|
||
| class ApplicationErrorArg { | ||
| public: | ||
| ApplicationErrorArg(); | ||
| ApplicationErrorArg(uint32_t error_code, const char* dialog_message, | ||
| const char* fullscreen_message, | ||
| const nn::settings::LanguageCode& languageCode); | ||
| void SetApplicationErrorCodeNumber(uint32_t error_code); | ||
| void SetDialogMessage(const char* message); | ||
| void SetFullScreenMessage(const char* message); | ||
|
|
||
| uint64_t unk; | ||
| uint32_t error_code; | ||
| nn::settings::LanguageCode language_code; | ||
| char dialog_message[2048]; | ||
| char fullscreen_message[2048]; | ||
| }; | ||
|
|
||
| uint32_t MakeErrorCode(ErrorCodeCategoryType err_category_type, uint32_t errorCodeNumber); | ||
| ErrorCode ConvertResultToErrorCode(const Result& result); | ||
| bool CreateErrorViewerStartupParamForRecordedError(void*, std::uint64_t*, std::uint64_t, | ||
| const char*, const char*, time::PosixTime); | ||
| void ExecuteJump(ErrorViewerJumpDestination destination); | ||
| void GetErrorCodeString(char* outErrorCodeString, std::size_t errorCodeStrBufferSize, | ||
| ErrorCode errorCode); | ||
| void* GetErrorMessageDatabaseVersion(ErrorMessageDatabaseVersion* outVersion); | ||
| ErrorCode MakeErrorCode(std::uint32_t category, std::uint32_t number); | ||
| void ShowApplicationError(const ApplicationErrorArg& arg); | ||
| void ShowError(Result result); | ||
| void ShowError(ErrorCode errorCode); | ||
| void ShowError(const ErrorResultVariant& errorResultVariant); | ||
| void ShowError(Result result, ResultBacktrace& backtrace); | ||
| void ShowErrorRecord(Result result, time::PosixTime timestamp); | ||
| void ShowErrorRecord(ErrorCode errorCode, time::PosixTime timestamp); | ||
| void ShowErrorRecord(const void*, std::uint64_t); | ||
| void ShowErrorWithoutJump(Result result); | ||
| void ShowErrorWithoutJump(ErrorCode errorCode); | ||
| void ShowEula(settings::system::RegionCode regionCode); | ||
| void ShowSystemError(const SystemErrorArg& arg); | ||
| void ShowSystemUpdateEula(settings::system::RegionCode regionCode, EulaData& data); | ||
| void ShowUnacceptableAddOnContentVersionError(); | ||
| void ShowUnacceptableApplicationVersionError(); | ||
| } // namespace nn::err | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #pragma once | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| namespace nn::err::detail { | ||
| // What does Flv stand for? | ||
| enum class MessageKind : std::uint8_t { DialogueMessage, DialogueButton, FlvMessage, FlvButton }; | ||
| } // namespace nn::err::detail |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #pragma once | ||
|
|
||
| #include <nn/settings.h> | ||
|
|
||
| namespace nn::err { | ||
| class ApplicationErrorArg { | ||
| public: | ||
| ApplicationErrorArg(); | ||
| ApplicationErrorArg(std::uint32_t errorCode, const char* dialogMessage, | ||
| const char* fullScreenMessage, const settings::LanguageCode& languageCode); | ||
|
|
||
| std::uint32_t GetApplicationErrorCodeNumber() const; | ||
| const char* GetDialogMessage() const; | ||
| const char* GetFullScreenMessage() const; | ||
| settings::LanguageCode GetLanguageCode() const; | ||
|
|
||
| void SetApplicationErrorCodeNumber(std::uint32_t errorCode); | ||
| void SetDialogMessage(const char* message); | ||
| void SetFullScreenMessage(const char* message); | ||
| void SetLanguageCode(const settings::LanguageCode& languageCode); | ||
|
|
||
| private: | ||
| std::int8_t _0 = 2; | ||
| std::int8_t _1 = 1; | ||
| std::int8_t padding[6]; | ||
| std::uint32_t m_ErrorCode = 0; | ||
| settings::LanguageCode m_LanguageCode; | ||
| char m_DialogMessage[2048]; | ||
| char m_FullScreenMessage[2048]; | ||
| }; | ||
| } // namespace nn::err |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #pragma once | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| namespace nn::err { | ||
| class ErrorCode { | ||
| public: | ||
| static ErrorCode GetInvalidErrorCode(); | ||
|
|
||
| ErrorCode() {} | ||
| ErrorCode(std::uint32_t category, std::uint32_t number) | ||
| : m_Category(category), m_Number(number) {} | ||
|
|
||
| bool IsValid() const; | ||
|
|
||
| std::uint32_t GetCategory() const { return m_Category; } | ||
| std::uint32_t GetNumber() const { return m_Number; } | ||
|
|
||
| private: | ||
| std::uint32_t m_Category = 0; | ||
| std::uint32_t m_Number = 0; | ||
| }; | ||
| } // namespace nn::err |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #pragma once | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| namespace nn::err { | ||
| class ErrorMessageDatabaseVersion { | ||
| public: | ||
| private: | ||
| std::int32_t m_Version; | ||
| }; | ||
|
|
||
| static_assert(sizeof(ErrorMessageDatabaseVersion) == 4); | ||
| } // namespace nn::err |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #pragma once | ||
|
|
||
| #include <nn/err/err_ErrorCode.h> | ||
| #include <nn/nn_Result.h> | ||
|
|
||
| namespace nn::err { | ||
| class ErrorResultVariant { | ||
| public: | ||
| enum class State : std::uint32_t { | ||
| Undefined, | ||
| Result, | ||
| ErrorCode, | ||
| }; | ||
|
|
||
| ErrorResultVariant(); | ||
| ErrorResultVariant(const Result& result); | ||
| ErrorResultVariant(const ErrorCode& errorCode); | ||
|
|
||
| State GetState() const; | ||
|
|
||
| operator ErrorCode() const; | ||
| operator Result() const; | ||
|
|
||
| ErrorResultVariant& operator=(const Result& result); | ||
| ErrorResultVariant& operator=(const ErrorCode& errorCode); | ||
|
|
||
| private: | ||
| State m_State = State::Undefined; | ||
| union { | ||
| Result m_Result; | ||
| ErrorCode m_ErrorCode; | ||
| } m_Value; | ||
| }; | ||
| } // namespace nn::err |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #pragma once | ||
|
|
||
| #include <nn/nn_Result.h> | ||
|
|
||
| namespace nn::err { | ||
| class ResultBacktrace { | ||
| public: | ||
| static void Make(ResultBacktrace* outBackTrace, const Result*, std::int32_t); | ||
|
|
||
| private: | ||
| // TODO | ||
| }; | ||
| } // namespace nn::err |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #pragma once | ||
|
|
||
| #include <nn/err/err_ErrorCode.h> | ||
| #include <nn/settings.h> | ||
|
|
||
| namespace nn::err { | ||
| class SystemErrorArg { | ||
| public: | ||
| SystemErrorArg(); | ||
| SystemErrorArg(ErrorCode errorCode, const char* dialogMessage, const char* fullScreenMessage, | ||
| const settings::LanguageCode& languageCode); | ||
|
|
||
| void SetErrorCode(ErrorCode errorCode); | ||
| void SetDialogMessage(const char* message); | ||
| void SetFullScreenMessage(const char* message); | ||
| void SetLanguageCode(const settings::LanguageCode& languageCode); | ||
| ErrorCode GetErrorCode() const; | ||
| const char* GetDialogMessage() const; | ||
| const char* GetFullScreenMessage() const; | ||
| settings::LanguageCode GetLanguageCode() const; | ||
| void GetStartupParam() const; | ||
|
|
||
| private: | ||
| std::int8_t _0 = 1; | ||
| std::int8_t _1 = 0; | ||
| std::int8_t _2 = 0; | ||
| std::int8_t _3 = 0; | ||
| std::int8_t _4 = 0; | ||
| std::int8_t _5 = 0; | ||
| std::int8_t _6 = 0; | ||
| std::int8_t _7 = 0; | ||
| ErrorCode m_ErrorCode; | ||
| settings::LanguageCode m_LanguageCode; | ||
| char m_DialogMessage[2048]; | ||
| char m_FullScreenMessage[2048]; | ||
| }; | ||
| } // namespace nn::err |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #pragma once | ||
|
|
||
| #include <nn/err.h> | ||
| #include <nn/err/detail/err_MessageKind.h> | ||
| #include <nn/err/err_ErrorCode.h> | ||
| #include <nn/settings.h> | ||
|
|
||
| namespace nn::ns { | ||
| // TODO: move | ||
| class ApplicationErrorCodeCategory { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we know what header should this be moved to? Prefer to define the class in the right header instead of at where it's used, so people don't duplicate the definitions later. |
||
| public: | ||
| const char* GetCategory() const { return m_Category; } | ||
|
|
||
| private: | ||
| char m_Category[8]; | ||
| }; | ||
| } // namespace nn::ns | ||
|
|
||
| namespace nn::err { | ||
| class ErrorMessageDatabaseVersion; | ||
| } // namespace nn::err | ||
|
|
||
| namespace nn::err::detail { | ||
| bool CategoryExists(std::uint32_t category); | ||
| bool DefaultErrorMessageDataExists(std::uint32_t category); | ||
| bool ErrorMessageDataExists(ErrorCode errorCode); | ||
| bool IsApplicationErrorCodeString(const char* errorCodeString); | ||
| void MakeApplicationErrorCodeString( | ||
| char* outErrorCodeString, std::size_t errorCodeStringBufferSize, | ||
| const ns::ApplicationErrorCodeCategory& applicationErrorCodeCategory, | ||
| std::uint32_t errorCodeNumber); | ||
| void MakeErrorCodeString(char* outErrorCodeString, std::size_t errorCodeStringBufferSize, | ||
| ErrorCode errorCode); | ||
| void MakeErrorInfoCommonFilePath(char* outErrorInfoCommonFilePath, | ||
| std::size_t errorInfoCommonFilePathBufferSize, | ||
| ErrorCode errorCode); | ||
| void MakeErrorInfoDirectoryPath(char* outErrorInfoDirectoryPath, | ||
| std::size_t errorInfoDirectoryPathBufferSize, ErrorCode errorCode); | ||
| void MakeErrorInfoMessageFilePath(char* outErrorInfoMessageFilePath, | ||
| std::size_t errorInfoMessageFilePathBufferSize, | ||
| ErrorCode errorCode, settings::LanguageCode languageCode, | ||
| MessageKind messageKind); | ||
| void MakeErrorInfoModuleDirectoryPath(char* outErrorInfoModuleDirectoryPath, | ||
| std::size_t errorInfoModuleDirectoryPathBufferSize, | ||
| std::uint32_t errorCodeCategory); | ||
| void ParseApplicationErrorCodeString( | ||
| ns::ApplicationErrorCodeCategory* outApplicationErrorCodeCategory, | ||
| std::uint32_t* outErrorCodeCategoryNumber, const char* errorCodeString); | ||
| void ParseErrorCodeString(ErrorCode* outErrorCode, const char* errorCodeString); | ||
| void* ReadMessageFile(char16_t* outBuffer, std::int32_t* outMessageLength, | ||
| std::size_t messageBufferSize, ErrorCode errorCode, | ||
| settings::LanguageCode languageCode, MessageKind messageKind); | ||
| void ReadMessageFile(char16_t* outBuffer, std::size_t bufferSize, const char* errorCodeString, | ||
| const settings::LanguageCode& languageCode); | ||
| void ReadVersion(ErrorMessageDatabaseVersion* outVersion); | ||
| bool TryParseApplicationErrorCodeString( | ||
| ns::ApplicationErrorCodeCategory* outApplicationErrorCodeCategory, | ||
| std::uint32_t* outErrorCodeCategoryNumber, const char* errorCodeString); | ||
| bool TryParseErrorCodeString(ErrorCode* outErrorCode, const char* errorCodeString); | ||
| } // namespace nn::err::detail | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,10 @@ | |
| #include <nn/fs/fs_Types.h> | ||
| #include <nn/nn_Result.h> | ||
|
|
||
| namespace nn::ncm { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be moved to |
||
| enum class SystemDataId : std::uint64_t { Err = 0x10000000000801 }; // TODO: move | ||
| } // namespace nn::ncm | ||
|
|
||
| namespace nn::fs { | ||
|
|
||
| /* | ||
|
|
@@ -12,6 +16,7 @@ namespace nn::fs { | |
| bool MountSdCardForDebug(const char* mount); | ||
|
|
||
| Result MountSdCard(const char* mountPoint); | ||
| Result MountSystemData(const char* mountPoint, ncm::SystemDataId id); | ||
| bool IsSdCardInserted(); | ||
| Result FormatSdCard(); | ||
| Result FormatSdCardDryRun(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,10 @@ struct FirmwareVersion { | |
| } | ||
| }; | ||
|
|
||
| struct RegionCode { | ||
| std::int32_t code; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have been using int32_t from cstdint (without the std:: prefix) throughout the code base, everywhere else in the PR too |
||
| }; | ||
|
|
||
| Result GetFirmwareVersion(FirmwareVersion*); | ||
| } // namespace system | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a more specific time_* header that can be used?