Initial commit

This commit is contained in:
Yaser
2026-08-13 19:50:53 +03:30
commit 38084458fe
879 changed files with 95198 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
# encoding: UTF-8
# frozen_string_literal: true
module API::V2
module ExceptionHandlers
def self.included(base)
base.instance_eval do
rescue_from Grape::Exceptions::ValidationErrors do |e|
errors_array = e.full_messages.map do |err|
err.split.last
end
error!({ errors: errors_array }, 422)
end
rescue_from Grape::Exceptions::MethodNotAllowed do |_e|
error!({ errors: 'server.method_not_allowed' }, 405)
end
rescue_from Grape::Exceptions::InvalidMessageBody do |_e|
error!({ errors: 'server.method.invalid_message_body' }, 400)
end
rescue_from Peatio::Auth::Error do |e|
report_exception(e)
error!({ errors: ['jwt.decode_and_verify'] }, 401)
end
rescue_from ActiveRecord::RecordNotFound do |_e|
error!({ errors: ['record.not_found'] }, 404)
end
rescue_from :all do |e|
report_exception(e)
error!({ errors: ['server.internal_error'] }, 500)
end
end
end
end
end