Skip to content

Commit

Permalink
Error handling on response when doing requests (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marketen authored Nov 15, 2023
1 parent 0e26f2f commit a65ca42
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/brain/src/modules/apiClients/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ export class StandardApi {
);
}
});
res.on("error", (e: ErrnoException) => {
reject(
new ApiError({
name: e.name || "Standard ApiError",
message: `${e.message}. ` || "",
errno: e.errno || -1,
code: e.code || "UNKNOWN",
path: endpoint,
syscall: method,
hostname: this.requestOptions.hostname || undefined,
address: e.address,
port: e.port,
})
);
});
});
}
);
Expand Down

0 comments on commit a65ca42

Please sign in to comment.