-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from paveg/http-status
Add 5xx and 4xx handling (Frequent errors handle)
- Loading branch information
Showing
6 changed files
with
103 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
danger-lgtm (1.0.2) | ||
danger-lgtm (1.0.3) | ||
danger-plugin-api (~> 1.0) | ||
|
||
GEM | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Lgtm | ||
# ErrorHandleable is module of error handling | ||
module ErrorHandleable | ||
# 4xx http status. | ||
CLIENT_ERRORS = [ | ||
Net::HTTPBadRequest, | ||
Net::HTTPForbidden, | ||
Net::HTTPNotFound | ||
].freeze | ||
# 5xx http status. | ||
SERVER_ERRORS = [ | ||
Net::HTTPInternalServerError, | ||
Net::HTTPBadGateway, | ||
Net::HTTPServiceUnavailable, | ||
Net::HTTPGatewayTimeOut | ||
].freeze | ||
|
||
# validate_response is response validating | ||
# | ||
# @param [Net::HTTPxxx] response Net::HTTP responses | ||
# @raise ::Lgtm::Errors::UnexpectedError | ||
# @return [void] | ||
# | ||
def validate_response(response) | ||
case response | ||
when *SERVER_ERRORS | ||
raise ::Lgtm::Errors::UnexpectedError | ||
when *CLIENT_ERRORS | ||
raise ::Lgtm::Errors::UnexpectedError | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Lgtm | ||
class Errors | ||
class UnexpectedError < StandardError | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lgtm | ||
VERSION = '1.0.2'.freeze | ||
VERSION = '1.0.3'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters