Defect #31387 » 0002-Don-t-rescue-Exception.patch
app/controllers/admin_controller.rb | ||
---|---|---|
54 | 54 |
begin |
55 | 55 |
Redmine::DefaultData::Loader::load(params[:lang]) |
56 | 56 |
flash[:notice] = l(:notice_default_data_loaded) |
57 |
rescue Exception => e
|
|
57 |
rescue => e |
|
58 | 58 |
flash[:error] = l(:error_can_t_load_default_data, ERB::Util.h(e.message)) |
59 | 59 |
end |
60 | 60 |
end |
... | ... | |
65 | 65 |
begin |
66 | 66 |
Mailer.deliver_test_email(User.current) |
67 | 67 |
flash[:notice] = l(:notice_email_sent, ERB::Util.h(User.current.mail)) |
68 |
rescue Exception => e
|
|
68 |
rescue => e |
|
69 | 69 |
flash[:error] = l(:notice_email_error, ERB::Util.h(Redmine::CodesetUtil.replace_invalid_utf8(e.message.dup))) |
70 | 70 |
end |
71 | 71 |
redirect_to settings_path(:tab => 'notifications') |
app/controllers/auth_sources_controller.rb | ||
---|---|---|
60 | 60 |
begin |
61 | 61 |
@auth_source.test_connection |
62 | 62 |
flash[:notice] = l(:notice_successful_connection) |
63 |
rescue Exception => e
|
|
63 |
rescue => e |
|
64 | 64 |
flash[:error] = l(:error_unable_to_connect, e.message) |
65 | 65 |
end |
66 | 66 |
redirect_to auth_sources_path |
app/controllers/issue_statuses_controller.rb | ||
---|---|---|
74 | 74 |
def destroy |
75 | 75 |
IssueStatus.find(params[:id]).destroy |
76 | 76 |
redirect_to issue_statuses_path |
77 |
rescue Exception => e
|
|
77 |
rescue => e |
|
78 | 78 |
flash[:error] = l(:error_unable_delete_issue_status, ERB::Util.h(e.message)) |
79 | 79 |
redirect_to issue_statuses_path |
80 | 80 |
end |
app/models/import.rb | ||
---|---|---|
67 | 67 |
begin |
68 | 68 |
content = File.read(filepath, 256) |
69 | 69 |
separator = [',', ';'].sort_by {|sep| content.count(sep) }.last |
70 |
rescue Exception => e
|
|
70 |
rescue => e |
|
71 | 71 |
end |
72 | 72 |
end |
73 | 73 |
wrapper = '"' |
... | ... | |
272 | 272 |
if file_exists? |
273 | 273 |
begin |
274 | 274 |
File.delete filepath |
275 |
rescue Exception => e
|
|
275 |
rescue => e |
|
276 | 276 |
logger.error "Unable to delete file #{filepath}: #{e.message}" if logger |
277 | 277 |
end |
278 | 278 |
end |
app/models/mail_handler.rb | ||
---|---|---|
53 | 53 |
# Receives an email and rescues any exception |
54 | 54 |
def self.safe_receive(*args) |
55 | 55 |
receive(*args) |
56 |
rescue Exception => e
|
|
56 |
rescue => e |
|
57 | 57 |
Rails.logger.error "MailHandler: an unexpected error occurred when receiving email: #{e.message}" |
58 | 58 |
return false |
59 | 59 |
end |
app/models/mailer.rb | ||
---|---|---|
705 | 705 |
# Log errors when raise_delivery_errors is set to false, Rails does not |
706 | 706 |
mail.raise_delivery_errors = true |
707 | 707 |
super |
708 |
rescue Exception => e
|
|
708 |
rescue => e |
|
709 | 709 |
if ActionMailer::Base.raise_delivery_errors |
710 | 710 |
raise e |
711 | 711 |
else |
app/models/query.rb | ||
---|---|---|
327 | 327 |
if self == ::Query |
328 | 328 |
# Visibility depends on permissions for each subclass, |
329 | 329 |
# raise an error if the scope is called from Query (eg. Query.visible) |
330 |
raise Exception.new("Cannot call .visible scope from the base Query class, but from subclasses only.")
|
|
330 |
raise "Cannot call .visible scope from the base Query class, but from subclasses only."
|
|
331 | 331 |
end |
332 | 332 | |
333 | 333 |
user = args.shift || User.current |
app/models/repository.rb | ||
---|---|---|
382 | 382 |
ret = "" |
383 | 383 |
begin |
384 | 384 |
ret = self.scm_adapter_class.client_command if self.scm_adapter_class |
385 |
rescue Exception => e
|
|
385 |
rescue => e |
|
386 | 386 |
logger.error "scm: error during get command: #{e.message}" |
387 | 387 |
end |
388 | 388 |
ret |
... | ... | |
392 | 392 |
ret = "" |
393 | 393 |
begin |
394 | 394 |
ret = self.scm_adapter_class.client_version_string if self.scm_adapter_class |
395 |
rescue Exception => e
|
|
395 |
rescue => e |
|
396 | 396 |
logger.error "scm: error during get version string: #{e.message}" |
397 | 397 |
end |
398 | 398 |
ret |
... | ... | |
402 | 402 |
ret = false |
403 | 403 |
begin |
404 | 404 |
ret = self.scm_adapter_class.client_available if self.scm_adapter_class |
405 |
rescue Exception => e
|
|
405 |
rescue => e |
|
406 | 406 |
logger.error "scm: error during get scm available: #{e.message}" |
407 | 407 |
end |
408 | 408 |
ret |
app/models/repository/git.rb | ||
---|---|---|
84 | 84 | |
85 | 85 |
def default_branch |
86 | 86 |
scm.default_branch |
87 |
rescue Exception => e
|
|
87 |
rescue => e |
|
88 | 88 |
logger.error "git: error during get default branch: #{e.message}" |
89 | 89 |
nil |
90 | 90 |
end |
app/models/tracker.rb | ||
---|---|---|
142 | 142 | |
143 | 143 |
private |
144 | 144 |
def check_integrity |
145 |
raise Exception.new("Cannot delete tracker") if Issue.where(:tracker_id => self.id).any?
|
|
145 |
raise "Cannot delete tracker" if Issue.where(:tracker_id => self.id).any?
|
|
146 | 146 |
end |
147 | 147 |
end |
bin/changelog.rb | ||
---|---|---|
133 | 133 | |
134 | 134 |
begin |
135 | 135 |
raise if items_per_page == 0 || @no_of_issues == 0 |
136 |
rescue Exception => e
|
|
136 |
rescue => e |
|
137 | 137 |
puts "No changelog items to process.\n" + |
138 | 138 |
"Make sure to provide a valid version id as the -i parameter." |
139 | 139 |
exit |
config/routes.rb | ||
---|---|---|
356 | 356 |
if File.exists?(file) |
357 | 357 |
begin |
358 | 358 |
instance_eval File.read(file) |
359 |
rescue Exception => e
|
|
359 |
rescue SyntaxError, StandardError => e
|
|
360 | 360 |
puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}." |
361 | 361 |
exit 1 |
362 | 362 |
end |
extra/mail_handler/rdm-mailhandler.rb | ||
---|---|---|
204 | 204 |
def read_key_from_file(filename) |
205 | 205 |
begin |
206 | 206 |
self.key = File.read(filename).strip |
207 |
rescue Exception => e
|
|
207 |
rescue => e |
|
208 | 208 |
$stderr.puts "Unable to read the key from #{filename}:\n#{e.message}" |
209 | 209 |
exit 1 |
210 | 210 |
end |
extra/svn/reposman.rb | ||
---|---|---|
54 | 54 |
def read_key_from_file(filename) |
55 | 55 |
begin |
56 | 56 |
$api_key = File.read(filename).strip |
57 |
rescue Exception => e
|
|
57 |
rescue => e |
|
58 | 58 |
$stderr.puts "Unable to read the key from #{filename}: #{e.message}" |
59 | 59 |
exit 1 |
60 | 60 |
end |
lib/redmine/plugin.rb | ||
---|---|---|
422 | 422 |
base_target_dir = File.join(destination, File.dirname(source_files.first).gsub(source, '')) |
423 | 423 |
begin |
424 | 424 |
FileUtils.mkdir_p(base_target_dir) |
425 |
rescue Exception => e
|
|
425 |
rescue => e |
|
426 | 426 |
raise "Could not create directory #{base_target_dir}: " + e.message |
427 | 427 |
end |
428 | 428 |
end |
... | ... | |
433 | 433 |
target_dir = File.join(destination, dir.gsub(source, '')) |
434 | 434 |
begin |
435 | 435 |
FileUtils.mkdir_p(target_dir) |
436 |
rescue Exception => e
|
|
436 |
rescue => e |
|
437 | 437 |
raise "Could not create directory #{target_dir}: " + e.message |
438 | 438 |
end |
439 | 439 |
end |
... | ... | |
444 | 444 |
unless File.exist?(target) && FileUtils.identical?(file, target) |
445 | 445 |
FileUtils.cp(file, target) |
446 | 446 |
end |
447 |
rescue Exception => e
|
|
447 |
rescue => e |
|
448 | 448 |
raise "Could not copy #{file} to #{target}: " + e.message |
449 | 449 |
end |
450 | 450 |
end |
lib/redmine/scm/adapters/abstract_adapter.rb | ||
---|---|---|
251 | 251 |
## Linux JRuby 1.6.2 (ruby-1.8.7-p330) raises java.io.IOException |
252 | 252 |
## in production environment. |
253 | 253 |
# rescue Errno::ENOENT => e |
254 |
rescue Exception => e
|
|
254 |
rescue => e |
|
255 | 255 |
msg = strip_credential(e.message) |
256 | 256 |
# The command failed, log it and re-raise |
257 | 257 |
logmsg = "SCM command failed, " |
... | ... | |
282 | 282 |
str.force_encoding(from) |
283 | 283 |
begin |
284 | 284 |
str.encode(to) |
285 |
rescue Exception => err
|
|
285 |
rescue => err |
|
286 | 286 |
logger.error("failed to convert from #{from} to #{to}. #{err}") |
287 | 287 |
nil |
288 | 288 |
end |
lib/redmine/scm/adapters/mercurial_adapter.rb | ||
---|---|---|
92 | 92 |
:lastrev => Revision.new(:revision => tip['revision'], |
93 | 93 |
:scmid => tip['node'])) |
94 | 94 |
# rescue HgCommandAborted |
95 |
rescue Exception => e
|
|
95 |
rescue => e |
|
96 | 96 |
logger.error "hg: error during getting info: #{e.message}" |
97 | 97 |
nil |
98 | 98 |
end |
lib/redmine/scm/adapters/subversion_adapter.rb | ||
---|---|---|
115 | 115 |
}) |
116 | 116 |
}) |
117 | 117 |
end |
118 |
rescue Exception => e
|
|
118 |
rescue => e |
|
119 | 119 |
logger.error("Error parsing svn output: #{e.message}") |
120 | 120 |
logger.error("Output was:\n #{output}") |
121 | 121 |
end |
lib/tasks/email.rake | ||
---|---|---|
164 | 164 |
begin |
165 | 165 |
Mailer.deliver_test_email(user) |
166 | 166 |
puts l(:notice_email_sent, user.mail) |
167 |
rescue Exception => e
|
|
167 |
rescue => e |
|
168 | 168 |
abort l(:notice_email_error, e.message) |
169 | 169 |
end |
170 | 170 |
end |
lib/tasks/locales.rake | ||
---|---|---|
168 | 168 |
puts "parsing #{filename}..." |
169 | 169 |
begin |
170 | 170 |
parser.parse File.open(filename) |
171 |
rescue Exception => e1
|
|
171 |
rescue => e1 |
|
172 | 172 |
puts(e1.message) |
173 | 173 |
puts("") |
174 | 174 |
end |
175 | 175 |
end |
176 |
rescue Exception => e
|
|
176 |
rescue => e |
|
177 | 177 |
puts(e.message) |
178 | 178 |
end |
179 | 179 |
end |
lib/tasks/migrate_from_trac.rake | ||
---|---|---|
614 | 614 |
raise "This directory doesn't exist!" unless File.directory?(path) |
615 | 615 |
raise "#{trac_attachments_directory} doesn't exist!" unless File.directory?(trac_attachments_directory) |
616 | 616 |
@@trac_directory |
617 |
rescue Exception => e
|
|
617 |
rescue => e |
|
618 | 618 |
puts e |
619 | 619 |
return false |
620 | 620 |
end |
... | ... | |
629 | 629 |
# If adapter is sqlite or sqlite3, make sure that trac.db exists |
630 | 630 |
raise "#{trac_db_path} doesn't exist!" if %w(sqlite3).include?(adapter) && !File.exist?(trac_db_path) |
631 | 631 |
@@trac_adapter = adapter |
632 |
rescue Exception => e
|
|
632 |
rescue => e |
|
633 | 633 |
puts e |
634 | 634 |
return false |
635 | 635 |
end |
test/functional/admin_controller_test.rb | ||
---|---|---|
75 | 75 | |
76 | 76 |
def test_load_default_configuration_data_should_rescue_error |
77 | 77 |
delete_configuration_data |
78 |
Redmine::DefaultData::Loader.stubs(:load).raises(Exception.new("Something went wrong"))
|
|
78 |
Redmine::DefaultData::Loader.stubs(:load).raises(StandardError.new("Something went wrong"))
|
|
79 | 79 |
post :default_configuration, :params => { |
80 | 80 |
:lang => 'fr' |
81 | 81 |
} |
... | ... | |
99 | 99 |
end |
100 | 100 | |
101 | 101 |
def test_test_email_failure_should_display_the_error |
102 |
Mailer.stubs(:test_email).raises(Exception, 'Some error message')
|
|
102 |
Mailer.stubs(:test_email).raises(StandardError, 'Some error message')
|
|
103 | 103 |
post :test_email |
104 | 104 |
assert_redirected_to '/settings?tab=notifications' |
105 | 105 |
assert_match /Some error message/, flash[:error] |
test/test_helper.rb | ||
---|---|---|
121 | 121 |
def self.ldap_configured? |
122 | 122 |
@test_ldap = Net::LDAP.new(:host => $redmine_test_ldap_server, :port => 389) |
123 | 123 |
return @test_ldap.bind |
124 |
rescue Exception => e
|
|
124 |
rescue => e |
|
125 | 125 |
# LDAP is not listening |
126 | 126 |
return nil |
127 | 127 |
end |
test/unit/issue_nested_set_concurrency_test.rb | ||
---|---|---|
84 | 84 |
ActiveRecord::Base.connection_pool.with_connection do |
85 | 85 |
begin |
86 | 86 |
yield |
87 |
rescue Exception => e
|
|
87 |
rescue => e |
|
88 | 88 |
Thread.current[:exception] = e.message |
89 | 89 |
end |
90 | 90 |
end |
test/unit/mail_handler_test.rb | ||
---|---|---|
1223 | 1223 |
end |
1224 | 1224 | |
1225 | 1225 |
def test_safe_receive_should_rescue_exceptions_and_return_false |
1226 |
MailHandler.stubs(:receive).raises(Exception.new "Something went wrong")
|
|
1226 |
MailHandler.stubs(:receive).raises(StandardError.new "Something went wrong")
|
|
1227 | 1227 | |
1228 | 1228 |
assert_equal false, MailHandler.safe_receive |
1229 | 1229 |
end |
test/unit/mailer_test.rb | ||
---|---|---|
915 | 915 | |
916 | 916 |
def test_should_raise_delivery_errors_when_raise_delivery_errors_is_true |
917 | 917 |
mail = Mailer.test_email(User.find(1)) |
918 |
mail.delivery_method.stubs(:deliver!).raises(Exception.new("delivery error"))
|
|
918 |
mail.delivery_method.stubs(:deliver!).raises(StandardError.new("delivery error"))
|
|
919 | 919 | |
920 | 920 |
ActionMailer::Base.raise_delivery_errors = true |
921 |
assert_raise Exception, "delivery error" do
|
|
921 |
assert_raise StandardError, "delivery error" do
|
|
922 | 922 |
mail.deliver |
923 | 923 |
end |
924 | 924 |
ensure |
... | ... | |
927 | 927 | |
928 | 928 |
def test_should_log_delivery_errors_when_raise_delivery_errors_is_false |
929 | 929 |
mail = Mailer.test_email(User.find(1)) |
930 |
mail.delivery_method.stubs(:deliver!).raises(Exception.new("delivery error"))
|
|
930 |
mail.delivery_method.stubs(:deliver!).raises(StandardError.new("delivery error"))
|
|
931 | 931 | |
932 | 932 |
Rails.logger.expects(:error).with("Email delivery error: delivery error") |
933 | 933 |
ActionMailer::Base.raise_delivery_errors = false |
test/unit/project_nested_set_concurrency_test.rb | ||
---|---|---|
52 | 52 |
c2.reload.destroy |
53 | 53 |
c1.reload.destroy |
54 | 54 |
end |
55 |
rescue Exception => e
|
|
55 |
rescue => e |
|
56 | 56 |
Thread.current[:exception] = e.message |
57 | 57 |
end |
58 | 58 |
end |
test/unit/tracker_test.rb | ||
---|---|---|
129 | 129 |
tracker = Tracker.find(1) |
130 | 130 | |
131 | 131 |
assert_no_difference 'Tracker.count' do |
132 |
assert_raise Exception do
|
|
132 |
assert_raise StandardError do
|
|
133 | 133 |
tracker.destroy |
134 | 134 |
end |
135 | 135 |
end |
- « Previous
- 1
- 2
- Next »