Module: ErrorsHelper

Defined in:
lib/errors_helper.rb,
lib/errors_helper/base.rb,
lib/errors_helper/version.rb,
lib/errors_helper/not_found.rb,
lib/errors_helper/bad_request.rb,
lib/errors_helper/unprocessable_entity.rb

Defined Under Namespace

Classes: BadRequest, Base, NotFound, UnprocessableEntity

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.build_response(code:) ⇒ Object



14
15
16
17
18
19
# File 'lib/errors_helper.rb', line 14

def self.build_response(code:)
  message = @codes.dig('error_code', code)
  return parse(@codes.dig('error_code', '99')) if message.nil?

  parse(message)
end

.list_errorsObject



21
22
23
24
# File 'lib/errors_helper.rb', line 21

def self.list_errors
  @codes.dig('error_code').each { |key, value| puts "#{key} : #{value}"}
  true
end