THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

Don't rescue Exception class (#31387).

Patch by Go MAEDA and Pavel Rosický.


git-svn-id: http://svn.redmine.org/redmine/trunk@18197 e93f8b46-1217-0410-a6f0-8f06a7374b81
pull/116/head
Go MAEDA 4 months ago
parent
commit
b0e17e8199

+ 2
- 2
app/controllers/admin_controller.rb View File

@@ -54,7 +54,7 @@ class AdminController < ApplicationController
begin
Redmine::DefaultData::Loader::load(params[:lang])
flash[:notice] = l(:notice_default_data_loaded)
rescue Exception => e
rescue => e
flash[:error] = l(:error_can_t_load_default_data, ERB::Util.h(e.message))
end
end
@@ -65,7 +65,7 @@ class AdminController < ApplicationController
begin
Mailer.deliver_test_email(User.current)
flash[:notice] = l(:notice_email_sent, ERB::Util.h(User.current.mail))
rescue Exception => e
rescue => e
flash[:error] = l(:notice_email_error, ERB::Util.h(Redmine::CodesetUtil.replace_invalid_utf8(e.message.dup)))
end
redirect_to settings_path(:tab => 'notifications')

+ 1
- 1
app/controllers/auth_sources_controller.rb View File

@@ -60,7 +60,7 @@ class AuthSourcesController < ApplicationController
begin
@auth_source.test_connection
flash[:notice] = l(:notice_successful_connection)
rescue Exception => e
rescue => e
flash[:error] = l(:error_unable_to_connect, e.message)
end
redirect_to auth_sources_path

+ 1
- 1
app/controllers/issue_statuses_controller.rb View File

@@ -74,7 +74,7 @@ class IssueStatusesController < ApplicationController
def destroy
IssueStatus.find(params[:id]).destroy
redirect_to issue_statuses_path
rescue Exception => e
rescue => e
flash[:error] = l(:error_unable_delete_issue_status, ERB::Util.h(e.message))
redirect_to issue_statuses_path
end

+ 2
- 2
app/models/import.rb View File

@@ -67,7 +67,7 @@ class Import < ActiveRecord::Base
begin
content = File.read(filepath, 256)
separator = [',', ';'].sort_by {|sep| content.count(sep) }.last
rescue Exception => e
rescue => e
end
end
wrapper = '"'
@@ -272,7 +272,7 @@ class Import < ActiveRecord::Base
if file_exists?
begin
File.delete filepath
rescue Exception => e
rescue => e
logger.error "Unable to delete file #{filepath}: #{e.message}" if logger
end
end

+ 1
- 1
app/models/mail_handler.rb View File

@@ -53,7 +53,7 @@ class MailHandler < ActionMailer::Base
# Receives an email and rescues any exception
def self.safe_receive(*args)
receive(*args)
rescue Exception => e
rescue => e
Rails.logger.error "MailHandler: an unexpected error occurred when receiving email: #{e.message}"
return false
end

+ 1
- 1
app/models/mailer.rb View File

@@ -705,7 +705,7 @@ class Mailer < ActionMailer::Base
# Log errors when raise_delivery_errors is set to false, Rails does not
mail.raise_delivery_errors = true
super
rescue Exception => e
rescue => e
if ActionMailer::Base.raise_delivery_errors
raise e
else

+ 1
- 1
app/models/query.rb View File

@@ -327,7 +327,7 @@ class Query < ActiveRecord::Base
if self == ::Query
# Visibility depends on permissions for each subclass,
# raise an error if the scope is called from Query (eg. Query.visible)
raise Exception.new("Cannot call .visible scope from the base Query class, but from subclasses only.")
raise "Cannot call .visible scope from the base Query class, but from subclasses only."
end

user = args.shift || User.current

+ 3
- 3
app/models/repository.rb View File

@@ -382,7 +382,7 @@ class Repository < ActiveRecord::Base
ret = ""
begin
ret = self.scm_adapter_class.client_command if self.scm_adapter_class
rescue Exception => e
rescue => e
logger.error "scm: error during get command: #{e.message}"
end
ret
@@ -392,7 +392,7 @@ class Repository < ActiveRecord::Base
ret = ""
begin
ret = self.scm_adapter_class.client_version_string if self.scm_adapter_class
rescue Exception => e
rescue => e
logger.error "scm: error during get version string: #{e.message}"
end
ret
@@ -402,7 +402,7 @@ class Repository < ActiveRecord::Base
ret = false
begin
ret = self.scm_adapter_class.client_available if self.scm_adapter_class
rescue Exception => e
rescue => e
logger.error "scm: error during get scm available: #{e.message}"
end
ret

+ 1
- 1
app/models/repository/git.rb View File

@@ -84,7 +84,7 @@ class Repository::Git < Repository

def default_branch
scm.default_branch
rescue Exception => e
rescue => e
logger.error "git: error during get default branch: #{e.message}"
nil
end

+ 1
- 1
app/models/tracker.rb View File

@@ -142,6 +142,6 @@ class Tracker < ActiveRecord::Base

private
def check_integrity
raise Exception.new("Cannot delete tracker") if Issue.where(:tracker_id => self.id).any?
raise "Cannot delete tracker" if Issue.where(:tracker_id => self.id).any?
end
end

+ 1
- 1
bin/changelog.rb View File

@@ -133,7 +133,7 @@ module Redmine

begin
raise if items_per_page == 0 || @no_of_issues == 0
rescue Exception => e
rescue => e
puts "No changelog items to process.\n" +
"Make sure to provide a valid version id as the -i parameter."
exit

+ 1
- 1
config/routes.rb View File

@@ -357,7 +357,7 @@ Rails.application.routes.draw do
if File.exists?(file)
begin
instance_eval File.read(file)
rescue Exception => e
rescue SyntaxError, StandardError => e
puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
exit 1
end

+ 1
- 1
extra/mail_handler/rdm-mailhandler.rb View File

@@ -204,7 +204,7 @@ END_DESC
def read_key_from_file(filename)
begin
self.key = File.read(filename).strip
rescue Exception => e
rescue => e
$stderr.puts "Unable to read the key from #{filename}:\n#{e.message}"
exit 1
end

+ 1
- 1
extra/svn/reposman.rb View File

@@ -54,7 +54,7 @@ end
def read_key_from_file(filename)
begin
$api_key = File.read(filename).strip
rescue Exception => e
rescue => e
$stderr.puts "Unable to read the key from #{filename}: #{e.message}"
exit 1
end

+ 3
- 3
lib/redmine/plugin.rb View File

@@ -422,7 +422,7 @@ module Redmine
base_target_dir = File.join(destination, File.dirname(source_files.first).gsub(source, ''))
begin
FileUtils.mkdir_p(base_target_dir)
rescue Exception => e
rescue => e
raise "Could not create directory #{base_target_dir}: " + e.message
end
end
@@ -433,7 +433,7 @@ module Redmine
target_dir = File.join(destination, dir.gsub(source, ''))
begin
FileUtils.mkdir_p(target_dir)
rescue Exception => e
rescue => e
raise "Could not create directory #{target_dir}: " + e.message
end
end
@@ -444,7 +444,7 @@ module Redmine
unless File.exist?(target) && FileUtils.identical?(file, target)
FileUtils.cp(file, target)
end
rescue Exception => e
rescue => e
raise "Could not copy #{file} to #{target}: " + e.message
end
end

+ 2
- 6
lib/redmine/scm/adapters/abstract_adapter.rb View File

@@ -247,11 +247,7 @@ module Redmine
io.close_write unless options[:write_stdin]
block.call(io) if block_given?
end
## If scm command does not exist,
## Linux JRuby 1.6.2 (ruby-1.8.7-p330) raises java.io.IOException
## in production environment.
# rescue Errno::ENOENT => e
rescue Exception => e
rescue => e
msg = strip_credential(e.message)
# The command failed, log it and re-raise
logmsg = "SCM command failed, "
@@ -282,7 +278,7 @@ module Redmine
str.force_encoding(from)
begin
str.encode(to)
rescue Exception => err
rescue => err
logger.error("failed to convert from #{from} to #{to}. #{err}")
nil
end

+ 1
- 1
lib/redmine/scm/adapters/mercurial_adapter.rb View File

@@ -92,7 +92,7 @@ module Redmine
:lastrev => Revision.new(:revision => tip['revision'],
:scmid => tip['node']))
# rescue HgCommandAborted
rescue Exception => e
rescue => e
logger.error "hg: error during getting info: #{e.message}"
nil
end

+ 1
- 1
lib/redmine/scm/adapters/subversion_adapter.rb View File

@@ -115,7 +115,7 @@ module Redmine
})
})
end
rescue Exception => e
rescue => e
logger.error("Error parsing svn output: #{e.message}")
logger.error("Output was:\n #{output}")
end

+ 1
- 1
lib/tasks/email.rake View File

@@ -164,7 +164,7 @@ END_DESC
begin
Mailer.deliver_test_email(user)
puts l(:notice_email_sent, user.mail)
rescue Exception => e
rescue => e
abort l(:notice_email_error, e.message)
end
end

+ 2
- 2
lib/tasks/locales.rake View File

@@ -168,12 +168,12 @@ END_DESC
puts "parsing #{filename}..."
begin
parser.parse File.open(filename)
rescue Exception => e1
rescue => e1
puts(e1.message)
puts("")
end
end
rescue Exception => e
rescue => e
puts(e.message)
end
end

+ 2
- 2
lib/tasks/migrate_from_trac.rake View File

@@ -614,7 +614,7 @@ namespace :redmine do
raise "This directory doesn't exist!" unless File.directory?(path)
raise "#{trac_attachments_directory} doesn't exist!" unless File.directory?(trac_attachments_directory)
@@trac_directory
rescue Exception => e
rescue => e
puts e
return false
end
@@ -629,7 +629,7 @@ namespace :redmine do
# If adapter is sqlite or sqlite3, make sure that trac.db exists
raise "#{trac_db_path} doesn't exist!" if %w(sqlite3).include?(adapter) && !File.exist?(trac_db_path)
@@trac_adapter = adapter
rescue Exception => e
rescue => e
puts e
return false
end

+ 2
- 2
test/functional/admin_controller_test.rb View File

@@ -75,7 +75,7 @@ class AdminControllerTest < Redmine::ControllerTest

def test_load_default_configuration_data_should_rescue_error
delete_configuration_data
Redmine::DefaultData::Loader.stubs(:load).raises(Exception.new("Something went wrong"))
Redmine::DefaultData::Loader.stubs(:load).raises(StandardError.new("Something went wrong"))
post :default_configuration, :params => {
:lang => 'fr'
}
@@ -99,7 +99,7 @@ class AdminControllerTest < Redmine::ControllerTest
end

def test_test_email_failure_should_display_the_error
Mailer.stubs(:test_email).raises(Exception, 'Some error message')
Mailer.stubs(:test_email).raises(StandardError, 'Some error message')
post :test_email
assert_redirected_to '/settings?tab=notifications'
assert_match /Some error message/, flash[:error]

+ 1
- 1
test/test_helper.rb View File

@@ -121,7 +121,7 @@ class ActiveSupport::TestCase
def self.ldap_configured?
@test_ldap = Net::LDAP.new(:host => $redmine_test_ldap_server, :port => 389)
return @test_ldap.bind
rescue Exception => e
rescue => e
# LDAP is not listening
return nil
end

+ 1
- 1
test/unit/issue_nested_set_concurrency_test.rb View File

@@ -84,7 +84,7 @@ class IssueNestedSetConcurrencyTest < ActiveSupport::TestCase
ActiveRecord::Base.connection_pool.with_connection do
begin
yield
rescue Exception => e
rescue => e
Thread.current[:exception] = e.message
end
end

+ 1
- 1
test/unit/mail_handler_test.rb View File

@@ -1223,7 +1223,7 @@ class MailHandlerTest < ActiveSupport::TestCase
end

def test_safe_receive_should_rescue_exceptions_and_return_false
MailHandler.stubs(:receive).raises(Exception.new "Something went wrong")
MailHandler.stubs(:receive).raises(StandardError.new "Something went wrong")

assert_equal false, MailHandler.safe_receive
end

+ 3
- 3
test/unit/mailer_test.rb View File

@@ -920,10 +920,10 @@ class MailerTest < ActiveSupport::TestCase

def test_should_raise_delivery_errors_when_raise_delivery_errors_is_true
mail = Mailer.test_email(User.find(1))
mail.delivery_method.stubs(:deliver!).raises(Exception.new("delivery error"))
mail.delivery_method.stubs(:deliver!).raises(StandardError.new("delivery error"))

ActionMailer::Base.raise_delivery_errors = true
assert_raise Exception, "delivery error" do
assert_raise StandardError, "delivery error" do
mail.deliver
end
ensure
@@ -932,7 +932,7 @@ class MailerTest < ActiveSupport::TestCase

def test_should_log_delivery_errors_when_raise_delivery_errors_is_false
mail = Mailer.test_email(User.find(1))
mail.delivery_method.stubs(:deliver!).raises(Exception.new("delivery error"))
mail.delivery_method.stubs(:deliver!).raises(StandardError.new("delivery error"))

Rails.logger.expects(:error).with("Email delivery error: delivery error")
ActionMailer::Base.raise_delivery_errors = false

+ 1
- 1
test/unit/project_nested_set_concurrency_test.rb View File

@@ -52,7 +52,7 @@ class ProjectNestedSetConcurrencyTest < ActiveSupport::TestCase
c2.reload.destroy
c1.reload.destroy
end
rescue Exception => e
rescue => e
Thread.current[:exception] = e.message
end
end

+ 1
- 1
test/unit/tracker_test.rb View File

@@ -129,7 +129,7 @@ class TrackerTest < ActiveSupport::TestCase
tracker = Tracker.find(1)

assert_no_difference 'Tracker.count' do
assert_raise Exception do
assert_raise StandardError do
tracker.destroy
end
end

Loading…
Cancel
Save