Module: Gat::Launcher::ClassMethods
- Defined in:
- lib/gat/launcher.rb
Instance Method Summary collapse
-
#launch(options, arguments) ⇒ Object
This method launches the Gatget Usage: class ExampleGatget < Gat::Base end options = { :specific_gatget_options }.
Instance Method Details
#launch(options, arguments) ⇒ Object
This method launches the Gatget Usage:
class ExampleGatget < Gat::Base
end
options = { :specific_gatget_options }
ExampleScript.launch(options, ARGV)
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/gat/launcher.rb', line 44 def launch(, arguments) launch_error = false # Load Instance gatget. # # Gatget exceptions are rescued by Instance Error if fails # Other exceptions are parsed as Undefined begin instance_gatget = self.new(, arguments) rescue GatgetException, GatgetConfigException, GatgetArgumentException => error launch_error = GatgetInstanceException.new(error, error.exception_location) rescue => error launch_error = UndefinedException.new(error, 'initialize_gatget') end # If no error, continue with the process unless launch_error # Gatget exceptions are rescued and parsed as is. # Other exceptions are parsed as Undefined begin instance_gatget.execute rescue GatgetException, GatgetProcessException, GatgetConfigException, GatgetArgumentException => error launch_error = error rescue => error launch_error = UndefinedException.new(error, 'launch_error') end # Rescue operations if launch_error and instance_gatget.methods.include?('onfail') begin instance_gatget.onfail_error = launch_error instance_gatget.logger.log("message", "failed_gatget", 'starting rescue operations for failed_gatget') instance_gatget.send('onfail') rescue => error $stderr.puts launch_error.exit_error # no controlled gatget failed, exit instance_gatget.logger.log("error", "failed_gatget", error.) error_string = error.methods.include?('exception_message') ? error. : error launch_error = GatgetFatalException.new(error_string, 'launch') end end end if launch_error $stderr.puts launch_error.exit_error exit launch_error.exit_level else # Success exit 0 end end |