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:



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

def initialize(err)
  @error = err
end

Instance Attribute Details

#errorGruf::Error|String (readonly)

Returns The error being serialized.

Returns:



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

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)


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

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)


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

def serialize
  raise NotImplementedError
end