[RMXP] Suppress errors

I have a game which, some of the time, *will* error, due to a network connection.

I have added to main this:

begin
# blah blah main script
rescue Exception => e
$scene = Scene_Error.new(e.message)
end



I want, instead of showing an alert as usual saying there has been an error, to send the player to a scene which shows a nicely printed message. I've called this Scene_Error.

The problem is that while this successfully stops the error message, the game closes after the error anyway. I think RMXP is merely programmed to do this (print error then close).

Can I suppress this close so that I can display my scene?

Nothing will be shown in this scene other than a window with some text in (from e.message).

Here is my scene if it's needed:

  1. class Scene_Error
  2.   def initialize(message)
  3.     @message = message
  4.   end
  5.  
  6.   def main
  7.     @help_window = Window_Help.new
  8.     @help_window.set_text(@message)
  9.     @help_window.y = 288
  10.    
  11.     Graphics.transition
  12.     loop do
  13.       Graphics.update
  14.       @help_window.update
  15.       if $scene != self
  16.         break
  17.       end
  18.     end
  19.    
  20.     Graphics.freeze
  21.     @help_window.dispose
  22.   end
  23. end
Expand to see the code.
If you've wrapped the main loop with the exception handling then it would be exiting outside the scope of the main loop, could that be the problem with it closing?
Aha! Thanks, seems logical now. Yeah it's outside of the main loop and $game_system and everything is destroyed before it gets to the exception. Sorted, cheers.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=77089