Class: Gruf::Serializers::Errors::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gruf/serializers/errors/base.rb

Overview

Base class for serialization of errors for transport across the grpc protocol

Direct Known Subclasses

Json

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(err) ⇒ Base

Returns a new instance of Base.

Parameters:



32
33
34
# File 'lib/gruf/serializers/errors/base.rb', line 32

def initialize(err)
  @error = err
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



27
28
29
# File 'lib/gruf/serializers/errors/base.rb', line 27

def error
  @error
end

Instance Method Details

#deserializeObject|Hash

Must be implemented in a derived class. This method should deserialize the error object that is transported over the gRPC trailing metadata payload.

Returns:

  • (Object|Hash)

    The deserialized error object

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/gruf/serializers/errors/base.rb', line 52

def deserialize
  raise NotImplementedError
end

#serializeString

Must be implemented in a derived class. This method should serialize the error into a transportable String that can be pushed into GRPC metadata across the wire.

Returns:

  • (String)

    The serialized error

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/gruf/serializers/errors/base.rb', line 42

def serialize
  raise NotImplementedError
end