From 72e3b0dd34491879bb55677e9ca78f13b2b8be63 Mon Sep 17 00:00:00 2001 From: Alula Date: Fri, 3 Apr 2026 20:36:36 +0200 Subject: [PATCH] erpt: Fix rare aborts caused by ResultInvalidPowerState --- .../source/erpt/srv/erpt_srv_reporter.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp index a1314cc77..d24736272 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_reporter.cpp @@ -423,7 +423,17 @@ namespace ams::erpt::srv { auto report = std::make_unique(record.get(), redirect_new_reports); R_UNLESS(report != nullptr, erpt::ResultOutOfMemory()); - auto report_guard = SCOPE_GUARD { const auto delete_res = report->Delete(); R_ASSERT(delete_res); AMS_UNUSED(delete_res); }; + auto report_guard = SCOPE_GUARD { + const auto delete_res = report->Delete(); + R_ASSERT(delete_res); + AMS_UNUSED(delete_res); + /* if (erpt::ResultInvalidPowerState::Includes(result)) { + * Nintendo ignores this and sends "power_state_violation" play report if this error happens. + * } else { + * Nintendo sends "write_failure" play report if any other error happens. + * } + */ + }; R_TRY(Context::WriteContextsToReport(report.get())); R_TRY(report->GetSize(std::addressof(record->m_info.report_size))); @@ -434,7 +444,7 @@ namespace ams::erpt::srv { } else { /* If we are redirecting new reports, we don't want to store the report in the journal. */ /* We should take this opportunity to delete any attachments associated with the report. */ - R_ABORT_UNLESS(JournalForAttachments::DeleteAttachments(report_id)); + R_TRY(JournalForAttachments::DeleteAttachments(report_id)); } R_TRY(Journal::Commit());