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



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

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