Refactor error classes
All runner errors are now in a single file. The not found error has been splitted into an error for runner not found and for environment not found.
This commit is contained in:

committed by
Sebastian Serth

parent
413f9b2705
commit
b48b45de9f
@ -38,7 +38,7 @@ class Runner < ApplicationRecord
|
||||
DELEGATED_STRATEGY_METHODS.each do |method|
|
||||
define_method(method) do |*args, &block|
|
||||
@strategy.send(method, *args, &block)
|
||||
rescue Runner::Error::NotFound
|
||||
rescue Runner::Error::RunnerNotFound
|
||||
request_new_id
|
||||
save
|
||||
@strategy.send(method, *args, &block)
|
||||
@ -55,13 +55,13 @@ class Runner < ApplicationRecord
|
||||
strategy_class = self.class.strategy_class
|
||||
self.runner_id = strategy_class.request_from_management(execution_environment)
|
||||
@strategy = strategy_class.new(runner_id, execution_environment)
|
||||
rescue Runner::Error::NotFound
|
||||
rescue Runner::Error::EnvironmentNotFound
|
||||
if strategy_class.sync_environment(execution_environment)
|
||||
raise Runner::Error::NotFound.new(
|
||||
raise Runner::Error::EnvironmentNotFound.new(
|
||||
"The execution environment with id #{execution_environment.id} was not found and was successfully synced with the runner management"
|
||||
)
|
||||
else
|
||||
raise Runner::Error::NotFound.new(
|
||||
raise Runner::Error::EnvironmentNotFound.new(
|
||||
"The execution environment with id #{execution_environment.id} was not found and could not be synced with the runner management"
|
||||
)
|
||||
end
|
||||
|
Reference in New Issue
Block a user