Sha256: 51934a4b1a461b64c1a0ec6efd942f82d390576ee3d3a0feaee38c722758caf1
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 KB
Contents
# frozen_string_literal: true # Refinements # ======================================================================= using NRSER # Definitions # ======================================================================= module Locd # Classes # ---------------------------------------------------------------------------- # Base class for errors that are to be expected and should be handled # gracefully. # class HandledError < StandardError; end # Base class for {HandledError} that happen during request processing which # should result in useful error responses to the user. # class RequestError < HandledError STATUS_CODE = 400 STATUS_MESSAGE = "Bad Request" def self.status "#{ self::STATUS_CODE } #{ self::STATUS_MESSAGE }" end # TODO document `text` attribute. # # @return [attr_type] # attr_reader :text def initialize text = self.class::STATUS_MESSAGE @text = text super "#{ self.class.status }\n\n#{ text }" end def to_http_response Locd.http_response_for self.class.status, text end def to_proxy_machine_cmd { close: to_http_response } end end # Raised when we couldn't find what the request seems to be looking for # (`404 Not Found` in HTTP). # class NotFoundError < RequestError STATUS_CODE = 404 STATUS_MESSAGE = "Not Found" end end # module Locd
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
locd-0.1.5 | lib/locd/errors.rb |
locd-0.1.4 | lib/locd/errors.rb |
locd-0.1.3 | lib/locd/errors.rb |