forked from hpyhacking/peatio
-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename: errors.rb exception_handlers.rb. Update specs. rescue_from :all
- Loading branch information
Yaroslav Savchuk
committed
Feb 18, 2019
1 parent
1f13cab
commit e6ed15e
Showing
8 changed files
with
57 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 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 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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters