Corrected with rubocop cop 'Lint/RescueException'.

This commit is contained in:
Thorsten Eckel 2015-05-08 16:09:24 +02:00
parent 6decb755f5
commit b6c2b6750a
17 changed files with 30 additions and 32 deletions

View file

@ -193,7 +193,5 @@ Style/Documentation:
Description: 'Document classes and non-namespace modules.'
Enabled: false
Lint/RescueException:
Enabled: false
Lint/UselessAssignment:
Enabled: false

View file

@ -287,7 +287,7 @@ class ApplicationController < ActionController::Base
generic_object.param_set_associations( params )
model_create_render_item(generic_object)
rescue Exception => e
rescue => e
logger.error e.message
logger.error e.backtrace.inspect
render json: { error: e.message }, status: :unprocessable_entity
@ -309,7 +309,7 @@ class ApplicationController < ActionController::Base
generic_object.param_set_associations( params )
model_update_render_item( generic_object )
rescue Exception => e
rescue => e
logger.error e.message
logger.error e.backtrace.inspect
render json: { error: e.message }, status: :unprocessable_entity
@ -323,7 +323,7 @@ class ApplicationController < ActionController::Base
generic_object = object.find( params[:id] )
generic_object.destroy
model_destory_render_item()
rescue Exception => e
rescue => e
logger.error e.message
logger.error e.backtrace.inspect
render json: { error: e.message }, status: :unprocessable_entity
@ -343,7 +343,7 @@ class ApplicationController < ActionController::Base
generic_object = object.find( params[:id] )
model_show_render_item(generic_object)
rescue Exception => e
rescue => e
logger.error e.message
logger.error e.backtrace.inspect
render json: { error: e.message }, status: :unprocessable_entity
@ -356,7 +356,7 @@ class ApplicationController < ActionController::Base
def model_index_render (object, _params)
generic_objects = object.all
model_index_render_result( generic_objects )
rescue Exception => e
rescue => e
logger.error e.message
logger.error e.backtrace.inspect
render json: { error: e.message }, status: :unprocessable_entity

View file

@ -628,7 +628,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
else
found = Channel::POP3.new.fetch( { options: params[:inbound][:options] }, 'verify', subject )
end
rescue Exception => e
rescue => e
render json: {
result: 'invalid',
message: e.to_s,
@ -762,7 +762,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
options: params[:options]
}
)
rescue Exception => e
rescue => e
# check if sending email was ok, but mailserver rejected
if !subject
@ -806,7 +806,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
mail,
nil
)
rescue Exception => e
rescue => e
message_human = ''
translation_map.each {|key, message|
if e.message =~ /#{Regexp.escape(key)}/i
@ -846,7 +846,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
begin
Channel::IMAP.new.fetch( { options: params[:options] }, 'check' )
rescue Exception => e
rescue => e
message_human = ''
translation_map.each {|key, message|
if e.message =~ /#{Regexp.escape(key)}/i
@ -869,7 +869,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
begin
Channel::POP3.new.fetch( { options: params[:options] }, 'check' )
rescue Exception => e
rescue => e
message_human = ''
translation_map.each {|key, message|
if e.message =~ /#{Regexp.escape(key)}/i
@ -896,7 +896,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
ress = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
ress.map { |r| [r.exchange.to_s, IPSocket.getaddress(r.exchange.to_s), r.preference] }
end
rescue Exception => e
rescue => e
logger.error e.message
logger.error e.backtrace.inspect
end

View file

@ -137,7 +137,7 @@ class LongPollingController < ApplicationController
return
end
end
rescue Exception => e
rescue => e
logger.error e.inspect
logger.error e.backtrace
render json: { error: 'Invalid client_id in receive loop!' }, status: :unprocessable_entity

View file

@ -176,7 +176,7 @@ class UsersController < ApplicationController
user_new = User.find( user.id )
render json: user_new, status: :created
rescue Exception => e
rescue => e
render json: { error: e.message }, status: :unprocessable_entity
end
end
@ -220,7 +220,7 @@ class UsersController < ApplicationController
# get new data
user_new = User.find( params[:id] )
render json: user_new, status: :ok
rescue Exception => e
rescue => e
render json: { error: e.message }, status: :unprocessable_entity
end
end

View file

@ -9,7 +9,7 @@ class Channel < ApplicationModel
begin
c = eval 'Channel::' + channel[:adapter].upcase + '.new' # rubocop:disable Lint/Eval
c.fetch(channel)
rescue Exception => e
rescue => e
logger.error "can't use " + 'Channel::' + channel[:adapter].upcase
logger.error e.inspect
logger.error e.backtrace

View file

@ -338,7 +338,7 @@ class Channel::EmailParser
filters.each {|_prio, backend|
begin
backend.run( channel, mail )
rescue Exception => e
rescue => e
Rails.logger.error "can't run postmaster pre filter #{backend}"
Rails.logger.error e.inspect
return false
@ -487,7 +487,7 @@ class Channel::EmailParser
filters.each {|_prio, backend|
begin
backend.run( channel, mail, ticket, article, user )
rescue Exception => e
rescue => e
Rails.logger.error "can't run postmaster post filter #{backend}"
Rails.logger.error e.inspect
end

View file

@ -8,7 +8,7 @@ module Channel::EmailSend
begin
c = eval 'Channel::' + channel[:adapter] + '.new' # rubocop:disable Lint/Eval
c.send(attr, channel, notification)
rescue Exception => e
rescue => e
Rails.logger.error "can't use " + 'Channel::' + channel[:adapter]
Rails.logger.error e.inspect
Rails.logger.error e.backtrace

View file

@ -25,7 +25,7 @@ module Channel::Filter::Database
Rails.logger.info " is not matching #{ key.downcase }:'#{ mail[ key.downcase.to_sym ] }' on #{value}"
match = false
end
rescue Exception => e
rescue => e
match = false
Rails.logger.error "can't use match rule #{value} on #{mail[ key.to_sym ]}"
Rails.logger.error e.inspect

View file

@ -29,7 +29,7 @@ class Channel::IMAP < Channel::EmailParser
# try LOGIN, if not - try plain
begin
@imap.authenticate( 'LOGIN', channel[:options][:user], channel[:options][:password] )
rescue Exception => e
rescue => e
if e.to_s !~ /(unsupported\s(authenticate|authentication)\smechanism|not\ssupported)/i
raise e
end

View file

@ -112,7 +112,7 @@ class Channel::TWITTER2
elsif tweet.respond_to?('from_user_id')
begin
sender = @client.user(tweet.from_user_id)
rescue Exception => e
rescue => e
Rails.logger.error 'Exception: twitter: ' + e.inspect
return
end

View file

@ -21,7 +21,7 @@ module Auth::Ldap
Rails.logger.info "Can't bind to '#{config[:host]}', #{ldap.get_operation_result.code}, #{ldap.get_operation_result.message}"
return
end
rescue Exception => e
rescue => e
Rails.logger.info "Can't connect to '#{config[:host]}', #{e}"
return
end

View file

@ -32,7 +32,7 @@ write a cache
end
begin
Rails.cache.write( key.to_s, data, params)
rescue Exception => e
rescue => e
Rails.logger.error "NOTICE: #{e.message}"
end
end

View file

@ -27,7 +27,7 @@ module Rss
break item if fetched == limit.to_i
}
Cache.write( cache_key, items, expires_in: 4.hours )
rescue Exception => e
rescue => e
Rails.logger.error "can't fetch #{url}"
Rails.logger.error e.inspect
return

View file

@ -266,7 +266,7 @@ returns
data[:user] = data_json['user'] # for compat. reasons
end
}
rescue Exception => e
rescue => e
Rails.logger.error e.inspect
destory(client_id)
Rails.logger.error "ERROR: reading session file '#{session_file}', remove session."

View file

@ -23,7 +23,7 @@ put working hours matrix and timezone in function, returns UTC working hours mat
if timezone
begin
time_diff = Time.zone.parse(start_time.to_s).in_time_zone(timezone).utc_offset
rescue Exception => e
rescue => e
Rails.logger.error "Can't fine tomezone #{timezone}"
Rails.logger.error e.inspect
Rails.logger.error e.backtrace

View file

@ -57,7 +57,7 @@ returns
begin
response = http.request(request)
return process(response, uri, count, params, options)
rescue Exception => e
rescue => e
return Result.new(
error: e.inspect,
success: false,
@ -105,7 +105,7 @@ returns
begin
response = http.request(request)
return process(response, uri, count, params, options)
rescue Exception => e
rescue => e
return Result.new(
error: e.inspect,
success: false,
@ -153,7 +153,7 @@ returns
begin
response = http.request(request)
return process(response, uri, count, params, options)
rescue Exception => e
rescue => e
return Result.new(
error: e.inspect,
success: false,
@ -194,7 +194,7 @@ returns
begin
response = http.request(request)
return process(response, uri, count, {}, options)
rescue Exception => e
rescue => e
return Result.new(
error: e.inspect,
success: false,