Skip to content

Commit e2ffdf9

Browse files
committed
Merge branch 'main' into task/CU-3d899qn_The-system-should-be-containerized
2 parents 4dfa324 + 8bfcc56 commit e2ffdf9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
class ApplicationController < ActionController::API
22
include Response
3+
include ExceptionHandler
34
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module ExceptionHandler
2+
extend ActiveSupport::Concern
3+
4+
included do
5+
rescue_from ActiveRecord::RecordNotFound do |e|
6+
json_response({ message: e.message }, :not_found)
7+
end
8+
9+
rescue_from ActiveRecord::RecordInvalid do |e|
10+
json_response({ message: e.message }, :unprocessable_entity)
11+
end
12+
end
13+
end

0 commit comments

Comments
 (0)