From d29852f7f0b0c2e4d1fee92a6c1a72e143d492c0 Mon Sep 17 00:00:00 2001 From: Nicko Guyer Date: Thu, 15 Jun 2023 09:11:01 -0400 Subject: [PATCH] Pass 409 Conflict back to FireFly Core Signed-off-by: Nicko Guyer --- 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 e321c4d..e622dab 100644 --- a/src/tokens/blockchain.service.ts +++ b/src/tokens/blockchain.service.ts @@ -17,6 +17,8 @@ import { ClientRequest } from 'http'; import { HttpService } from '@nestjs/axios'; import { + ConflictException, + HttpStatus, Injectable, InternalServerErrorException, Logger, @@ -94,7 +96,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; });