Skip to content

Refactor Exceptions: remove ScreenshotException. add OperationFailedExceptionWithScreenshot. - #1431

Merged
Mysticial merged 15 commits into
PokemonAutomation:mainfrom
jw098:exception2
Aug 29, 2026
Merged

Refactor Exceptions: remove ScreenshotException. add OperationFailedExceptionWithScreenshot.#1431
Mysticial merged 15 commits into
PokemonAutomation:mainfrom
jw098:exception2

Conversation

@jw098

@jw098 jw098 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Unfortunately, this is a massive PR.

I think the main things to review are all the files within Exception/. And the ProgramSessions, where the exceptions are caught.

@jw098
jw098 marked this pull request as draft August 27, 2026 17:26
e.send_notification(env, m_option.instance().NOTIFICATION_ERROR_FATAL);
send_program_fatal_error_notification(env, m_option.instance().NOTIFICATION_ERROR_FATAL, e.message(), *e.screenshot());
if (e.error_report_mode() == ErrorReport::SEND_ERROR_REPORT){
PokemonAutomation::report_error(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this pattern appears 35 times, then that's a lot of places to copy-paste inline it. Can you add back a helper function somewhere that does this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, basically, you want to go from this:

send_program_fatal_error_notification(env, m_option.instance().NOTIFICATION_ERROR_FATAL, e.message(), *e.screenshot());
if (e.error_report_mode() == ErrorReport::SEND_ERROR_REPORT){
    PokemonAutomation::report_error(
        &env.logger(),
        env.program_info(),
        "Fatal: OperationFailedExceptionWithScreenshot",
        {{"Message:", e.message()}},
        *e.screenshot(),
        &e.video_stream()->history()
    );
}

to this?

  send_program_fatal_error_notification_and_telemetry_report(
      env, &env.logger(), env.program_info(), 
      m_option.instance().NOTIFICATION_ERROR_FATAL, 
      e.error_report_mode(),
      e.message(),
      "OperationFailedExceptionWithScreenshot",
      *e.screenshot(),
      &e.video_stream()->history()
  );

@Mysticial Mysticial Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I mean back to a one-line function call like what it was before. I don't necessarily mean revert it, but make a helper function that does that.

Basically copying the same 10 lines 35 times when it's a clean 1 line each is not great.

@jw098
jw098 marked this pull request as ready for review August 29, 2026 06:09
@Mysticial
Mysticial merged commit 37e9789 into PokemonAutomation:main Aug 29, 2026
7 checks passed
@jw098
jw098 deleted the exception2 branch August 29, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants