Skip to content

Commit

Permalink
Guard against undefined method errors
Browse files Browse the repository at this point in the history
Not all errors returned here will have an error_type method.  In some
cases these errors are just structs.
  • Loading branch information
brianstien committed May 5, 2017
1 parent f933f7a commit 676ed90
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/active_remote/rpc_adapters/protobuf_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def execute(rpc_method, request_args)
private

def protobuf_error_class(error)
return ::ActiveRemote::ActiveRemoteError unless error.respond_to?(:error_type)

case error.error_type
when ::Protobuf::Socketrpc::ErrorReason::BAD_REQUEST_DATA
::ActiveRemote::BadRequestDataError
Expand All @@ -60,7 +62,7 @@ def protobuf_error_class(error)
when ::Protobuf::Socketrpc::ErrorReason::IO_ERROR
::ActiveRemote::IOError
else
ActiveRemoteError
::ActiveRemote::ActiveRemoteError
end
end

Expand Down

0 comments on commit 676ed90

Please sign in to comment.