class Cuprum::Rails::Serializers::Json::ErrorSerializer

Converts a Cuprum::Error to JSON using the as_json method.

Public Instance Methods

call(error, **_) click to toggle source

Converts the Cuprum error to JSON.

Calls and returns the as_json method of the error.

@param error [Cuprum::Error] The error to convert to JSON.

@return [Hash] a JSON-compatible representation of the error.

# File lib/cuprum/rails/serializers/json/error_serializer.rb, line 16
def call(error, **_)
  unless error.is_a?(Cuprum::Error)
    raise ArgumentError, 'object must be a Cuprum::Error'
  end

  error.as_json
end