| Index: third_party/grpc/src/ruby/lib/grpc/errors.rb
|
| diff --git a/third_party/protobuf/ruby/lib/google/protobuf.rb b/third_party/grpc/src/ruby/lib/grpc/errors.rb
|
| similarity index 58%
|
| copy from third_party/protobuf/ruby/lib/google/protobuf.rb
|
| copy to third_party/grpc/src/ruby/lib/grpc/errors.rb
|
| index f0eb626824f23b6dcd858ec820d57bcd246439de..2227ee1f12b503d3ee92b89e11ad042412cda5c4 100644
|
| --- a/third_party/protobuf/ruby/lib/google/protobuf.rb
|
| +++ b/third_party/grpc/src/ruby/lib/grpc/errors.rb
|
| @@ -1,6 +1,5 @@
|
| -# Protocol Buffers - Google's data interchange format
|
| -# Copyright 2008 Google Inc. All rights reserved.
|
| -# https://developers.google.com/protocol-buffers/
|
| +# Copyright 2015-2016, Google Inc.
|
| +# All rights reserved.
|
| #
|
| # Redistribution and use in source and binary forms, with or without
|
| # modification, are permitted provided that the following conditions are
|
| @@ -28,45 +27,36 @@
|
| # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -# require mixins before we hook them into the java & c code
|
| -require 'google/protobuf/message_exts'
|
| -
|
| -# We define these before requiring the platform-specific modules.
|
| -# That way the module init can grab references to these.
|
| -module Google
|
| - module Protobuf
|
| - class Error < StandardError; end
|
| - class ParseError < Error; end
|
| - end
|
| -end
|
| -
|
| -if RUBY_PLATFORM == "java"
|
| - require 'json'
|
| - require 'google/protobuf_java'
|
| -else
|
| - require 'google/protobuf_c'
|
| -end
|
| -
|
| -require 'google/protobuf/repeated_field'
|
| -
|
| -module Google
|
| - module Protobuf
|
| -
|
| - def self.encode(msg)
|
| - msg.to_proto
|
| - end
|
| -
|
| - def self.encode_json(msg)
|
| - msg.to_json
|
| +require 'grpc/grpc'
|
| +
|
| +# GRPC contains the General RPC module.
|
| +module GRPC
|
| + # BadStatus is an exception class that indicates that an error occurred at
|
| + # either end of a GRPC connection. When raised, it indicates that a status
|
| + # error should be returned to the other end of a GRPC connection; when
|
| + # caught it means that this end received a status error.
|
| + class BadStatus < StandardError
|
| + attr_reader :code, :details, :metadata
|
| +
|
| + # @param code [Numeric] the status code
|
| + # @param details [String] the details of the exception
|
| + def initialize(code, details = 'unknown cause', **kw)
|
| + super("#{code}:#{details}")
|
| + @code = code
|
| + @details = details
|
| + @metadata = kw
|
| end
|
|
|
| - def self.decode(klass, proto)
|
| - klass.decode(proto)
|
| - end
|
| -
|
| - def self.decode_json(klass, json)
|
| - klass.decode_json(json)
|
| + # Converts the exception to a GRPC::Status for use in the networking
|
| + # wrapper layer.
|
| + #
|
| + # @return [Status] with the same code and details
|
| + def to_status
|
| + Struct::Status.new(code, details, @metadata)
|
| end
|
| + end
|
|
|
| + # Cancelled is an exception class that indicates that an rpc was cancelled.
|
| + class Cancelled < StandardError
|
| end
|
| end
|
|
|