From 54ff874838fa300b4ced9765526c54d1eda4c6f5 Mon Sep 17 00:00:00 2001 From: Jonas Auer Date: Mon, 25 Jul 2022 22:07:01 +0200 Subject: [PATCH] Log URL of failed Neucore requests --- packages/backend/src/neucore/neucore-client.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/neucore/neucore-client.ts b/packages/backend/src/neucore/neucore-client.ts index fc1f172..fc682cc 100644 --- a/packages/backend/src/neucore/neucore-client.ts +++ b/packages/backend/src/neucore/neucore-client.ts @@ -19,10 +19,11 @@ export class NeucoreError extends Error { export class NeucoreResponseError extends NeucoreError { constructor( message: string, + path: string, public readonly response: Response, underlyingError?: Error ) { - super(message, underlyingError) + super(message + ` (while fetching ${path})`, underlyingError) } } @@ -64,6 +65,7 @@ export class NeucoreClient { } catch (error) { throw new NeucoreResponseError( 'Failed to parse response', + path, response, error ) @@ -71,6 +73,7 @@ export class NeucoreClient { } throw new NeucoreResponseError( `Received unexpected status code: ${response.status}`, + path, response ) }