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; });