mirror of
https://github.com/PabloMK7/citra
synced 2024-11-15 05:08:23 +00:00
result: Make error description a generic integer
It is now known that result code description vary depending on the module, and so they're best defined on a per-module basis. To support this, allow passing in an arbitrary integer instead of limiting to the ones in the ErrorDescription enum. These will be gradually migrated to their individual users, but a few will be kept as "common" codes shared by all modules.
This commit is contained in:
parent
a75145a2c6
commit
3b1f0fea31
3 changed files with 18 additions and 6 deletions
|
@ -13,9 +13,14 @@
|
||||||
|
|
||||||
// All the constants in this file come from http://3dbrew.org/wiki/Error_codes
|
// All the constants in this file come from http://3dbrew.org/wiki/Error_codes
|
||||||
|
|
||||||
/// Detailed description of the error. This listing is likely incomplete.
|
/**
|
||||||
|
* Detailed description of the error. Code 0 always means success. Codes 1000 and above are
|
||||||
|
* considered "well-known" and have common values between all modules. The meaning of other codes
|
||||||
|
* vary by module.
|
||||||
|
*/
|
||||||
enum class ErrorDescription : u32 {
|
enum class ErrorDescription : u32 {
|
||||||
Success = 0,
|
Success = 0,
|
||||||
|
|
||||||
SessionClosedByRemote = 26,
|
SessionClosedByRemote = 26,
|
||||||
WrongPermission = 46,
|
WrongPermission = 46,
|
||||||
OS_InvalidBufferDescriptor = 48,
|
OS_InvalidBufferDescriptor = 48,
|
||||||
|
@ -45,6 +50,8 @@ enum class ErrorDescription : u32 {
|
||||||
FS_UnsupportedOpenFlags = 760,
|
FS_UnsupportedOpenFlags = 760,
|
||||||
FS_IncorrectExeFSReadSize = 761,
|
FS_IncorrectExeFSReadSize = 761,
|
||||||
FS_UnexpectedFileOrDirectory = 770,
|
FS_UnexpectedFileOrDirectory = 770,
|
||||||
|
|
||||||
|
// Codes 1000 and above are considered "well-known" and have common values between all modules.
|
||||||
InvalidSection = 1000,
|
InvalidSection = 1000,
|
||||||
TooLarge = 1001,
|
TooLarge = 1001,
|
||||||
NotAuthorized = 1002,
|
NotAuthorized = 1002,
|
||||||
|
@ -218,7 +225,7 @@ enum class ErrorLevel : u32 {
|
||||||
union ResultCode {
|
union ResultCode {
|
||||||
u32 raw;
|
u32 raw;
|
||||||
|
|
||||||
BitField<0, 10, ErrorDescription> description;
|
BitField<0, 10, u32> description;
|
||||||
BitField<10, 8, ErrorModule> module;
|
BitField<10, 8, ErrorModule> module;
|
||||||
|
|
||||||
BitField<21, 6, ErrorSummary> summary;
|
BitField<21, 6, ErrorSummary> summary;
|
||||||
|
@ -230,7 +237,11 @@ union ResultCode {
|
||||||
|
|
||||||
constexpr explicit ResultCode(u32 raw) : raw(raw) {}
|
constexpr explicit ResultCode(u32 raw) : raw(raw) {}
|
||||||
|
|
||||||
constexpr ResultCode(ErrorDescription description_, ErrorModule module_, ErrorSummary summary_,
|
constexpr ResultCode(ErrorDescription description, ErrorModule module, ErrorSummary summary,
|
||||||
|
ErrorLevel level)
|
||||||
|
: ResultCode(static_cast<u32>(description), module, summary, level) {}
|
||||||
|
|
||||||
|
constexpr ResultCode(u32 description_, ErrorModule module_, ErrorSummary summary_,
|
||||||
ErrorLevel level_)
|
ErrorLevel level_)
|
||||||
: raw(description.FormatValue(description_) | module.FormatValue(module_) |
|
: raw(description.FormatValue(description_) | module.FormatValue(module_) |
|
||||||
summary.FormatValue(summary_) | level.FormatValue(level_)) {}
|
summary.FormatValue(summary_) | level.FormatValue(level_)) {}
|
||||||
|
|
|
@ -411,7 +411,8 @@ ResultCode UpdateConfigNANDSavegame() {
|
||||||
ResultCode FormatConfig() {
|
ResultCode FormatConfig() {
|
||||||
ResultCode res = DeleteConfigNANDSaveFile();
|
ResultCode res = DeleteConfigNANDSaveFile();
|
||||||
// The delete command fails if the file doesn't exist, so we have to check that too
|
// The delete command fails if the file doesn't exist, so we have to check that too
|
||||||
if (!res.IsSuccess() && res.description != ErrorDescription::FS_FileNotFound) {
|
if (!res.IsSuccess() &&
|
||||||
|
res.description != static_cast<u32>(ErrorDescription::FS_FileNotFound)) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
// Delete the old data
|
// Delete the old data
|
||||||
|
@ -534,7 +535,7 @@ ResultCode LoadConfigNANDSaveFile() {
|
||||||
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
|
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SystemSaveData, archive_path);
|
||||||
|
|
||||||
// If the archive didn't exist, create the files inside
|
// If the archive didn't exist, create the files inside
|
||||||
if (archive_result.Code().description == ErrorDescription::FS_NotFormatted) {
|
if (archive_result.Code().description == static_cast<u32>(ErrorDescription::FS_NotFormatted)) {
|
||||||
// Format the archive to create the directories
|
// Format the archive to create the directories
|
||||||
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SystemSaveData,
|
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SystemSaveData,
|
||||||
FileSys::ArchiveFormatInfo(), archive_path);
|
FileSys::ArchiveFormatInfo(), archive_path);
|
||||||
|
|
|
@ -134,7 +134,7 @@ void Init() {
|
||||||
auto archive_result =
|
auto archive_result =
|
||||||
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
|
Service::FS::OpenArchive(Service::FS::ArchiveIdCode::SharedExtSaveData, archive_path);
|
||||||
// If the archive didn't exist, create the files inside
|
// If the archive didn't exist, create the files inside
|
||||||
if (archive_result.Code().description == ErrorDescription::FS_NotFormatted) {
|
if (archive_result.Code().description == static_cast<u32>(ErrorDescription::FS_NotFormatted)) {
|
||||||
// Format the archive to create the directories
|
// Format the archive to create the directories
|
||||||
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData,
|
Service::FS::FormatArchive(Service::FS::ArchiveIdCode::SharedExtSaveData,
|
||||||
FileSys::ArchiveFormatInfo(), archive_path);
|
FileSys::ArchiveFormatInfo(), archive_path);
|
||||||
|
|
Loading…
Reference in a new issue