Skip to content

Commit

Permalink
Fix: Add EHOSTUNREACH and EPROTO error handler (#1190)
Browse files Browse the repository at this point in the history
* Fix: Add EHOSTUNREACH and EPROTO error handler

* Add more context for error 99

* Fix eproto description
  • Loading branch information
dennypradipta authored Nov 21, 2023
1 parent 22b2014 commit 5d7ec72
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/components/probe/prober/http/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,23 +413,36 @@ function getErrorStatusWithExplanation(error: unknown): {
}
}

case 'EHOSTUNREACHED': {
case 'EHOSTUNREACH': {
return {
status: 16,
description: 'EHOSTUNREACHED: The host is unreachable.',
description: 'EHOSTUNREACH: The host is unreachable.',
}
}

case 'EPROTO': {
return {
status: 17,
description:
"EPROTO: There are issues with the website's SSL/TLS certificates, incompatible protocols, or other SSL-related problems.",
}
}

default: {
if (error instanceof AxiosError) {
console.error(
`Unhandled error while probing ${error.request.url}, got ${error.code} ${error.stack} `
`Error code 99: Unhandled error while probing ${error.request.url}, got ${error.code} ${error.stack} `
)
} else {
console.error(`Unhandled error, got ${(error as AxiosError).stack}`)
console.error(
`Error code 99: Unhandled error, got ${(error as AxiosError).stack}`
)
}

return { status: 99, description: '' }
return {
status: 99,
description: `Error code 99: ${(error as AxiosError).stack}`,
}
} // in the event an unlikely unknown error, send here
}
}

0 comments on commit 5d7ec72

Please sign in to comment.