Skip to content

Commit 7cfd6cb

Browse files
authored
chore: differentiate between timeouts and other type of errors when no Axios response is available in our GC Notify connector (#5663)
* chore: differentiate between timeouts and other type of errors when no Axios response is available in our GC Notify connector * bump package
1 parent d54b225 commit 7cfd6cb

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

packages/connectors/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gcforms/connectors",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"author": "Canadian Digital Service",
55
"license": "MIT",
66
"publishConfig": {

packages/connectors/src/gc-notify-connector.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getAwsSecret } from "./getAwsSecret";
2-
import axios from "axios";
2+
import axios, { AxiosError } from "axios";
33

44
const API_URL: string = "https://api.notification.canada.ca";
55

@@ -57,6 +57,7 @@ export class GCNotifyConnector {
5757
});
5858
} catch (error) {
5959
let errorMessage = "";
60+
6061
if (axios.isAxiosError(error)) {
6162
if (error.response) {
6263
/*
@@ -73,7 +74,14 @@ export class GCNotifyConnector {
7374
* is an instance of XMLHttpRequest in the browser and an instance
7475
* of http.ClientRequest in Node.js
7576
*/
76-
errorMessage = `Request timed out`;
77+
78+
if (error.code === AxiosError.ECONNABORTED) {
79+
errorMessage = `Request timed out`;
80+
} else {
81+
errorMessage = `Error code: ${error.code ?? "n/a"} / Error stack: ${
82+
error.stack ?? "n/a"
83+
}`;
84+
}
7785
}
7886
} else if (error instanceof Error) {
7987
errorMessage = `${(error as Error).message}`;

0 commit comments

Comments
 (0)