Class: Griffin::Interceptors::Server::RailsExceptionInterceptor

Inherits:
GRPC::ServerInterceptor
  • Object
show all
Defined in:
lib/griffin/interceptors/server/rails_exception_interceptor.rb

Instance Method Summary collapse

Instance Method Details

#request_responseObject Also known as: server_streamer, client_streamer, bidi_streamer



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/griffin/interceptors/server/rails_exception_interceptor.rb', line 9

def request_response(*)
  begin
    yield
  rescue ActiveRecord::RecordNotFound => e
    Raven.capture_exception(e)
    raise GRPC::NotFound.new(e.message)
  rescue ActiveRecord::StaleObjectError => e
    Raven.capture_exception(e)
    raise GRPC::Aborted.new(e.message)
  rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved => e
    Raven.capture_exception(e)
    raise GRPC::FailedPrecondition.new(e.message)
  end
end