From 5d7ec721def70b8e2925551d095dc53c689f9483 Mon Sep 17 00:00:00 2001 From: Denny Pradipta Date: Tue, 21 Nov 2023 10:51:14 +0700 Subject: [PATCH] Fix: Add EHOSTUNREACH and EPROTO error handler (#1190) * Fix: Add EHOSTUNREACH and EPROTO error handler * Add more context for error 99 * Fix eproto description --- src/components/probe/prober/http/request.ts | 23 ++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/components/probe/prober/http/request.ts b/src/components/probe/prober/http/request.ts index c47f3fc47..84fd067b4 100644 --- a/src/components/probe/prober/http/request.ts +++ b/src/components/probe/prober/http/request.ts @@ -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 } }