File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
packages/wallet/backend/src/walletAddressKeys Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ import { v4 as uuid } from 'uuid'
55import { WalletAddressKeys } from './model'
66import { WalletAddressService } from '@/walletAddress/service'
77import { WalletAddress } from '@/walletAddress/model'
8- import { NotFound } from '@shared/backend'
8+ import { BadRequest , NotFound } from '@shared/backend'
9+ import { UniqueViolationError } from 'objection'
910
1011export type KeyResponse = {
1112 privateKey : string
@@ -91,7 +92,15 @@ export class WalletAddressKeyService implements IWalletAddressKeyService {
9192 walletAddressId
9293 }
9394
94- await WalletAddressKeys . query ( ) . insert ( key )
95+ try {
96+ await WalletAddressKeys . query ( ) . insert ( key )
97+ } catch ( e ) {
98+ if ( e instanceof UniqueViolationError )
99+ throw new BadRequest (
100+ 'Same key already uploaded. Please upload a unique one.'
101+ )
102+ else throw e
103+ }
95104 }
96105
97106 async registerKey ( {
You can’t perform that action at this time.
0 commit comments