Module: Lgtm::ErrorHandleable

Included in:
Danger::DangerLgtm
Defined in:
lib/lgtm/error_handleable.rb

Overview

ErrorHandleable is module of error handling

Constant Summary collapse

CLIENT_ERRORS =

4xx http status.

[
  Net::HTTPBadRequest,
  Net::HTTPForbidden,
  Net::HTTPNotFound
].freeze
SERVER_ERRORS =

5xx http status.

[
  Net::HTTPInternalServerError,
  Net::HTTPBadGateway,
  Net::HTTPServiceUnavailable,
  Net::HTTPGatewayTimeOut
].freeze

Instance Method Summary collapse

Instance Method Details

#validate_response(response) ⇒ void

This method returns an undefined value.

validate_response is response validating

Parameters:

  • response (Net::HTTPxxx)

    Net::HTTP responses

Raises:

  • ::Lgtm::Errors::UnexpectedError



24
25
26
27
28
29
30
31
# File 'lib/lgtm/error_handleable.rb', line 24

def validate_response(response)
  case response
  when *SERVER_ERRORS
    raise ::Lgtm::Errors::UnexpectedError
  when *CLIENT_ERRORS
    raise ::Lgtm::Errors::UnexpectedError
  end
end