diff --git a/app/controllers/concerns/lti.rb b/app/controllers/concerns/lti.rb index 023e445f..4eef7590 100644 --- a/app/controllers/concerns/lti.rb +++ b/app/controllers/concerns/lti.rb @@ -95,7 +95,7 @@ module Lti private :return_to_consumer def send_score(score) - raise Error.new("Score #{score} must be between 0 and #{MAXIMUM_SCORE}!") unless (0..MAXIMUM_SCORE).include?(score) + fail(Error, "Score #{score} must be between 0 and #{MAXIMUM_SCORE}!") unless (0..MAXIMUM_SCORE).include?(score) provider = build_tool_provider(consumer: Consumer.find_by(id: session[:consumer_id]), parameters: session[:lti_parameters]) if provider.nil? {status: 'error'} diff --git a/app/policies/application_policy.rb b/app/policies/application_policy.rb index 485e656c..5596f322 100644 --- a/app/policies/application_policy.rb +++ b/app/policies/application_policy.rb @@ -21,7 +21,7 @@ class ApplicationPolicy private :no_one def require_user! - raise Pundit::NotAuthorizedError unless @user + fail Pundit::NotAuthorizedError unless @user end private :require_user! @@ -33,7 +33,7 @@ class ApplicationPolicy end def require_user! - raise Pundit::NotAuthorizedError unless @user + fail Pundit::NotAuthorizedError unless @user end private :require_user! end diff --git a/lib/assessor.rb b/lib/assessor.rb index 2009e990..177b99e1 100644 --- a/lib/assessor.rb +++ b/lib/assessor.rb @@ -17,7 +17,7 @@ class Assessor if options[:execution_environment].testing_framework? @testing_framework_adapter = Kernel.const_get(options[:execution_environment].testing_framework).new else - raise Error.new('No testing framework adapter set!') + fail(Error, 'No testing framework adapter set!') end end end diff --git a/lib/code_ocean/config.rb b/lib/code_ocean/config.rb index 9570bb7f..0f27f0dd 100644 --- a/lib/code_ocean/config.rb +++ b/lib/code_ocean/config.rb @@ -10,7 +10,7 @@ module CodeOcean content = options[:erb] ? YAML.load(ERB.new(::File.new(path, 'r').read).result) : YAML.load_file(path) content[Rails.env].with_indifferent_access else - raise Error.new("Configuration file not found: #{path}") + fail(Error, "Configuration file not found: #{path}") end end end diff --git a/lib/docker_client.rb b/lib/docker_client.rb index 51d9c38b..7d66b3cc 100644 --- a/lib/docker_client.rb +++ b/lib/docker_client.rb @@ -10,7 +10,7 @@ class DockerClient def self.check_availability! Timeout::timeout(config[:connection_timeout]) { Docker.version } rescue Excon::Errors::SocketError, Timeout::Error - raise Error.new("The Docker host at #{Docker.url} is not reachable!") + raise(Error, "The Docker host at #{Docker.url} is not reachable!") end def command_substitutions(filename) @@ -96,12 +96,12 @@ class DockerClient @execution_environment = options[:execution_environment] @user = options[:user] @image = self.class.find_image_by_tag(@execution_environment.docker_image) - raise Error.new("Cannot find image #{@execution_environment.docker_image}!") unless @image + fail(Error, "Cannot find image #{@execution_environment.docker_image}!") unless @image end def self.initialize_environment unless config[:connection_timeout] && config[:workspace_root] - raise Error.new('Docker configuration missing!') + fail(Error, 'Docker configuration missing!') end Docker.url = config[:host] if config[:host] check_availability! diff --git a/lib/testing_framework_adapter.rb b/lib/testing_framework_adapter.rb index 15d4e28b..01d01d7e 100644 --- a/lib/testing_framework_adapter.rb +++ b/lib/testing_framework_adapter.rb @@ -15,7 +15,7 @@ class TestingFrameworkAdapter end def parse_output(output) - raise NotImplementedError.new("#{self.class} should implement #parse_output!") + fail(NotImplementedError, "#{self.class} should implement #parse_output!") end private :parse_output