|
@@ -15,6 +15,7 @@ module ApplicationController::HandlesErrors
|
|
|
rescue_from Exceptions::NotAuthorized, with: :unauthorized
|
|
|
rescue_from Exceptions::Forbidden, with: :forbidden
|
|
|
rescue_from Pundit::NotAuthorizedError, with: :pundit_not_authorized_error
|
|
|
+ rescue_from Store::Provider::S3::Error, with: :unprocessable_entity
|
|
|
end
|
|
|
|
|
|
def not_found(e)
|
|
@@ -87,9 +88,7 @@ module ApplicationController::HandlesErrors
|
|
|
end
|
|
|
|
|
|
def humanize_error(e)
|
|
|
- data = {
|
|
|
- error: e.message
|
|
|
- }
|
|
|
+ data = { error: e.message }
|
|
|
|
|
|
if (base_error = e.try(:record)&.errors&.messages&.find { |key, _| key.match? %r{[\w+.]?base} }&.last&.last)
|
|
|
data[:error_human] = base_error
|
|
@@ -105,7 +104,7 @@ module ApplicationController::HandlesErrors
|
|
|
elsif e.message == 'Exceptions::NotAuthorized'
|
|
|
data[:error] = __('Authorization failed')
|
|
|
data[:error_human] = data[:error]
|
|
|
- elsif [ActionController::RoutingError, ActiveRecord::RecordNotFound, Exceptions::UnprocessableEntity, Exceptions::NotAuthorized, Exceptions::Forbidden].include?(e.class)
|
|
|
+ elsif [ActionController::RoutingError, ActiveRecord::RecordNotFound, Exceptions::UnprocessableEntity, Exceptions::NotAuthorized, Exceptions::Forbidden, Store::Provider::S3::Error].include?(e.class)
|
|
|
data[:error_human] = data[:error]
|
|
|
end
|
|
|
|