Fix new rubocop warnings

This commit is contained in:
Tom Hughes 2019-04-23 09:25:47 +01:00
parent 7354c8eb13
commit 9f57f60b87
18 changed files with 80 additions and 80 deletions

View file

@ -114,18 +114,18 @@ module Api
def amf_handle_error(call, rootobj, rootid)
yield
rescue OSM::APIAlreadyDeletedError => ex
[-4, ex.object, ex.object_id]
rescue OSM::APIVersionMismatchError => ex
[-3, [rootobj, rootid], [ex.type.downcase, ex.id, ex.latest]]
rescue OSM::APIUserChangesetMismatchError => ex
[-2, ex.to_s]
rescue OSM::APIBadBoundingBox => ex
[-2, "Sorry - I can't get the map for that area. The server said: #{ex}"]
rescue OSM::APIError => ex
[-1, ex.to_s]
rescue StandardError => ex
[-2, "An unusual error happened (in #{call}). The server said: #{ex}"]
rescue OSM::APIAlreadyDeletedError => e
[-4, e.object, e.object_id]
rescue OSM::APIVersionMismatchError => e
[-3, [rootobj, rootid], [e.type.downcase, e.id, e.latest]]
rescue OSM::APIUserChangesetMismatchError => e
[-2, e.to_s]
rescue OSM::APIBadBoundingBox => e
[-2, "Sorry - I can't get the map for that area. The server said: #{e}"]
rescue OSM::APIError => e
[-1, e.to_s]
rescue StandardError => e
[-2, "An unusual error happened (in #{call}). The server said: #{e}"]
end
def amf_handle_error_with_timeout(call, rootobj, rootid)

View file

@ -364,10 +364,10 @@ module Api
end
# stupid Time seems to throw both of these for bad parsing, so
# we have to catch both and ensure the correct code path is taken.
rescue ArgumentError => ex
raise OSM::APIBadUserInput, ex.message.to_s
rescue RuntimeError => ex
raise OSM::APIBadUserInput, ex.message.to_s
rescue ArgumentError => e
raise OSM::APIBadUserInput, e.message.to_s
rescue RuntimeError => e
raise OSM::APIBadUserInput, e.message.to_s
end
##

View file

@ -22,8 +22,8 @@ module Api
bbox = BoundingBox.from_bbox_params(params)
bbox.check_boundaries
bbox.check_size
rescue StandardError => err
report_error(err.message)
rescue StandardError => e
report_error(e.message)
return
end

View file

@ -25,8 +25,8 @@ module Api
bbox = BoundingBox.from_bbox_params(params)
bbox.check_boundaries
bbox.check_size
rescue StandardError => err
report_error(err.message)
rescue StandardError => e
report_error(e.message)
return
end

View file

@ -37,8 +37,8 @@ class ApplicationController < ActionController::Base
elsif session[:token]
session[:user] = current_user.id if self.current_user = User.authenticate(:token => session[:token])
end
rescue StandardError => ex
logger.info("Exception authorizing user: #{ex}")
rescue StandardError => e
logger.info("Exception authorizing user: #{e}")
reset_session
self.current_user = nil
end
@ -185,22 +185,22 @@ class ApplicationController < ActionController::Base
def api_call_handle_error
yield
rescue ActiveRecord::RecordNotFound => ex
rescue ActiveRecord::RecordNotFound => e
head :not_found
rescue LibXML::XML::Error, ArgumentError => ex
report_error ex.message, :bad_request
rescue ActiveRecord::RecordInvalid => ex
message = "#{ex.record.class} #{ex.record.id}: "
ex.record.errors.each { |attr, msg| message << "#{attr}: #{msg} (#{ex.record[attr].inspect})" }
rescue LibXML::XML::Error, ArgumentError => e
report_error e.message, :bad_request
rescue ActiveRecord::RecordInvalid => e
message = "#{e.record.class} #{e.record.id}: "
e.record.errors.each { |attr, msg| message << "#{attr}: #{msg} (#{e.record[attr].inspect})" }
report_error message, :bad_request
rescue OSM::APIError => ex
report_error ex.message, ex.status
rescue AbstractController::ActionNotFound => ex
rescue OSM::APIError => e
report_error e.message, e.status
rescue AbstractController::ActionNotFound => e
raise
rescue StandardError => ex
logger.info("API threw unexpected #{ex.class} exception: #{ex.message}")
ex.backtrace.each { |l| logger.info(l) }
report_error "#{ex.class}: #{ex.message}", :internal_server_error
rescue StandardError => e
logger.info("API threw unexpected #{e.class} exception: #{e.message}")
e.backtrace.each { |l| logger.info(l) }
report_error "#{e.class}: #{e.message}", :internal_server_error
end
##
@ -227,11 +227,11 @@ class ApplicationController < ActionController::Base
OSM::Timer.timeout(Settings.web_timeout, Timeout::Error) do
yield
end
rescue ActionView::Template::Error => ex
ex = ex.cause
rescue ActionView::Template::Error => e
e = e.cause
if ex.is_a?(Timeout::Error) ||
(ex.is_a?(ActiveRecord::StatementInvalid) && ex.message =~ /execution expired/)
if e.is_a?(Timeout::Error) ||
(e.is_a?(ActiveRecord::StatementInvalid) && e.message =~ /execution expired/)
render :action => "timeout"
else
raise

View file

@ -98,8 +98,8 @@ class GeocoderController < ApplicationController
end
render :action => "results"
rescue StandardError => ex
@error = "Error contacting geocoder.ca: #{ex}"
rescue StandardError => e
@error = "Error contacting geocoder.ca: #{e}"
render :action => "error"
end
@ -166,8 +166,8 @@ class GeocoderController < ApplicationController
end
render :action => "results"
rescue StandardError => ex
@error = "Error contacting nominatim.openstreetmap.org: #{ex}"
rescue StandardError => e
@error = "Error contacting nominatim.openstreetmap.org: #{e}"
render :action => "error"
end
@ -198,8 +198,8 @@ class GeocoderController < ApplicationController
end
render :action => "results"
rescue StandardError => ex
@error = "Error contacting api.geonames.org: #{ex}"
rescue StandardError => e
@error = "Error contacting api.geonames.org: #{e}"
render :action => "error"
end
@ -230,8 +230,8 @@ class GeocoderController < ApplicationController
end
render :action => "results"
rescue StandardError => ex
@error = "Error contacting nominatim.openstreetmap.org: #{ex}"
rescue StandardError => e
@error = "Error contacting nominatim.openstreetmap.org: #{e}"
render :action => "error"
end
@ -261,8 +261,8 @@ class GeocoderController < ApplicationController
end
render :action => "results"
rescue StandardError => ex
@error = "Error contacting api.geonames.org: #{ex}"
rescue StandardError => e
@error = "Error contacting api.geonames.org: #{e}"
render :action => "error"
end

View file

@ -113,8 +113,8 @@ class TracesController < ApplicationController
begin
@trace = do_create(params[:trace][:gpx_file], params[:trace][:tagstring],
params[:trace][:description], params[:trace][:visibility])
rescue StandardError => ex
logger.debug ex
rescue StandardError => e
logger.debug e
end
if @trace.id