hackaru-app/hackaru-api

View on GitHub
app/models/api_error.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

class ApiError
  attr_reader :message, :status

  def initialize(key)
    @key = key
    @message = translate[:message]
    @status = translate[:status]
  end

  private

  def scope
    :error_renderer
  end

  def translate
    I18n.t(@key, scope: scope, default: :default)
  end
end