From fe6b37311bcb9f87dbd564a07462c81f2fa4707f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Wed, 18 Oct 2023 12:02:23 +0100 Subject: [PATCH] chore: Improve Unifrom error logging --- api.planx.uk/send/uniform.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api.planx.uk/send/uniform.ts b/api.planx.uk/send/uniform.ts index 919eb32cba..e0d5b4580c 100644 --- a/api.planx.uk/send/uniform.ts +++ b/api.planx.uk/send/uniform.ts @@ -1,4 +1,4 @@ -import axios, { AxiosRequestConfig } from "axios"; +import axios, { AxiosRequestConfig, isAxiosError } from "axios"; import { NextFunction, Request, Response } from "express"; import { Buffer } from "node:buffer"; import FormData from "form-data"; @@ -157,9 +157,11 @@ export async function sendToUniform( application: applicationAuditRecord, }); } catch (error) { + let loggedError = error; + if (isAxiosError(error)) loggedError = error.toJSON(); return next({ error, - message: `Failed to send to Uniform (${localAuthority}): ${error}`, + message: `Failed to send to Uniform (${localAuthority}): ${loggedError}`, }); } }