From 714a848a836b6beefa3b604f06ffd892343dcb0c Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Thu, 28 Sep 2023 13:36:25 -0400 Subject: [PATCH] Pass 409 Conflict back to FireFly Core Signed-off-by: Andrew Richardson --- src/tokens/blockchain.service.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/tokens/blockchain.service.ts b/src/tokens/blockchain.service.ts index 90018ba..8b36aeb 100644 --- a/src/tokens/blockchain.service.ts +++ b/src/tokens/blockchain.service.ts @@ -18,6 +18,8 @@ import { ClientRequest } from 'http'; import { HttpService } from '@nestjs/axios'; import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'; import { + ConflictException, + HttpStatus, Injectable, InternalServerErrorException, Logger, @@ -96,7 +98,13 @@ export class BlockchainConnectorService { this.logger.warn( `${request?.path} <-- HTTP ${response?.status} ${response?.statusText}: ${errorMessage}`, ); - throw new InternalServerErrorException(errorMessage); + if (response?.status === HttpStatus.CONFLICT) { + // Pass a 409 through + throw new ConflictException(errorMessage); + } else { + // Otherwise always return a 500 if the blockchain connector request wasn't successful + throw new InternalServerErrorException(errorMessage); + } } throw err; });