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:



29
30
31
# File 'lib/gruf/serializers/errors/base.rb', line 29

def initialize(err)
  @error = err
end

Instance Attribute Details

#errorGruf::Error|String (readonly)

Returns The error being serialized.

Returns:



24
25
26
# File 'lib/gruf/serializers/errors/base.rb', line 24

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)


49
50
51
# File 'lib/gruf/serializers/errors/base.rb', line 49

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)


39
40
41
# File 'lib/gruf/serializers/errors/base.rb', line 39

def serialize
  raise NotImplementedError
end