Method: OpenC3.handle_fatal_exception

Defined in:
lib/openc3/top_level.rb

.handle_fatal_exception(error, try_gui = true) ⇒ Object

Write a message to the Logger, write an exception file, and popup a GUI window if try_gui. Finally ‘exit 1’ is called to end the calling program.

Parameters:

  • error (Exception)

    The exception to handle

  • try_gui (Boolean) (defaults to: true)

    Whether to try and create a GUI exception popup



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
# File 'lib/openc3/top_level.rb', line 365

def self.handle_fatal_exception(error, try_gui = true)
  unless error.class == SystemExit or error.class == Interrupt
    $openc3_fatal_exception = error
    self.write_exception_file(error)
    Logger.level = Logger::FATAL
    Logger.fatal "Fatal Exception! Exiting..."
    Logger.fatal error.formatted
    if $stdout != STDOUT
      $stdout = STDOUT
      Logger.fatal "Fatal Exception! Exiting..."
      Logger.fatal error.formatted
    end
    sleep 1 # Allow the messages to be printed and then crash
    exit 1
  else
    exit 0
  end
end