Skip to content

Commit

Permalink
Merge pull request #392 from ZIMkaRU/feature/extend-network-error-pro…
Browse files Browse the repository at this point in the history
…cessing

Extend network error processing
  • Loading branch information
ezewer authored Aug 28, 2024
2 parents 0c38ac8 + 1f78350 commit 0fc54d2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
16 changes: 14 additions & 2 deletions workers/loc.api/helpers/api-errors-testers.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ const isEAiAgainError = (err) => {
}

const isEConnRefusedError = (err) => {
return /ECONNREFUSED/i.test(_getErrorString(err))
return /(ECONNREFUSED)|(ERR_CONNECTION_REFUSED)/i.test(_getErrorString(err))
}

const isEConnClosedError = (err) => {
return /ERR_CONNECTION_CLOSED/i.test(_getErrorString(err))
}

const isENotFoundError = (err) => {
Expand All @@ -71,6 +75,10 @@ const isTempUnavailableError = (err) => {
return /temporarily_unavailable/i.test(_getErrorString(err))
}

const isBadGatewayError = (err) => {
return /Bad Gateway/i.test(_getErrorString(err))
}

const isForbiddenError = (err) => {
return /forbidden/i.test(_getErrorString(err))
}
Expand All @@ -87,11 +95,13 @@ const isENetError = (err) => (
isNodeFetchTimeoutError(err) ||
isEAiAgainError(err) ||
isEConnRefusedError(err) ||
isEConnClosedError(err) ||
isENotFoundError(err) ||
isESocketTimeoutError(err) ||
isEHostUnreachError(err) ||
isEProtoError(err) ||
isTempUnavailableError(err)
isTempUnavailableError(err) ||
isBadGatewayError(err)
)

module.exports = {
Expand All @@ -106,11 +116,13 @@ module.exports = {
isNodeFetchTimeoutError,
isEAiAgainError,
isEConnRefusedError,
isEConnClosedError,
isENotFoundError,
isESocketTimeoutError,
isEHostUnreachError,
isEProtoError,
isTempUnavailableError,
isBadGatewayError,
isENetError,
isForbiddenError,
isMaintenanceError
Expand Down
10 changes: 10 additions & 0 deletions workers/loc.api/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ const {
isNodeFetchTimeoutError,
isEAiAgainError,
isEConnRefusedError,
isEConnClosedError,
isENotFoundError,
isESocketTimeoutError,
isEHostUnreachError,
isEProtoError,
isTempUnavailableError,
isBadGatewayError,
isENetError,
isForbiddenError,
isMaintenanceError
Expand Down Expand Up @@ -81,8 +86,13 @@ module.exports = {
isNodeFetchTimeoutError,
isEAiAgainError,
isEConnRefusedError,
isEConnClosedError,
isENotFoundError,
isESocketTimeoutError,
isEHostUnreachError,
isEProtoError,
isTempUnavailableError,
isBadGatewayError,
isENetError,
isForbiddenError,
isMaintenanceError,
Expand Down

0 comments on commit 0fc54d2

Please sign in to comment.