better error message
This commit is contained in:
@@ -15,6 +15,11 @@ class ErrorsController < ActionController::Base
|
|||||||
'/api/templates/docx'
|
'/api/templates/docx'
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
|
SAFE_ERROR_MESSAGE_CLASSES = [
|
||||||
|
ActionDispatch::Http::Parameters::ParseError,
|
||||||
|
JSON::ParserError
|
||||||
|
].freeze
|
||||||
|
|
||||||
def show
|
def show
|
||||||
if request.original_fullpath.in?(ENTERPRISE_PATHS) && error_status_code == 404
|
if request.original_fullpath.in?(ENTERPRISE_PATHS) && error_status_code == 404
|
||||||
return render json: { status: 404, message: ENTERPRISE_FEATURE_MESSAGE }, status: :not_found
|
return render json: { status: 404, message: ENTERPRISE_FEATURE_MESSAGE }, status: :not_found
|
||||||
@@ -24,7 +29,11 @@ class ErrorsController < ActionController::Base
|
|||||||
f.json do
|
f.json do
|
||||||
set_cors_headers
|
set_cors_headers
|
||||||
|
|
||||||
render json: { status: error_status_code }, status: error_status_code
|
exception = request.env['action_dispatch.exception']
|
||||||
|
|
||||||
|
error = exception.message if exception.class.in?(SAFE_ERROR_MESSAGE_CLASSES)
|
||||||
|
|
||||||
|
render json: { status: error_status_code, error: }.compact, status: error_status_code
|
||||||
end
|
end
|
||||||
|
|
||||||
f.html { render error_status_code.to_s, status: error_status_code }
|
f.html { render error_status_code.to_s, status: error_status_code }
|
||||||
|
|||||||
@@ -128,7 +128,12 @@ Rails.application.configure do
|
|||||||
config.lograge.formatter = ->(data) { data.except(:path, :location).to_json }
|
config.lograge.formatter = ->(data) { data.except(:path, :location).to_json }
|
||||||
|
|
||||||
config.lograge.custom_payload do |controller|
|
config.lograge.custom_payload do |controller|
|
||||||
params = controller.request.try(:params) || {}
|
params =
|
||||||
|
begin
|
||||||
|
controller.request.try(:params) || {}
|
||||||
|
rescue StandardError
|
||||||
|
{}
|
||||||
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
fwd: controller.request.ip,
|
fwd: controller.request.ip,
|
||||||
|
|||||||
Reference in New Issue
Block a user