@@ -3,6 +3,7 @@ import { FastifyInstance } from "fastify";
33import { StatusCodes } from "http-status-codes" ;
44import { WalletType } from "../../../schema/wallet" ;
55import { getConfig } from "../../../utils/cache/getConfig" ;
6+ import { createCustomError } from "../../middleware/error" ;
67import { standardResponseSchema } from "../../schemas/sharedApiSchemas" ;
78import { importAwsKmsWallet } from "../../utils/wallets/importAwsKmsWallet" ;
89import { importGcpKmsWallet } from "../../utils/wallets/importGcpKmsWallet" ;
@@ -135,16 +136,20 @@ export const importBackendWallet = async (fastify: FastifyInstance) => {
135136 password,
136137 } ) ;
137138 } else {
138- throw new Error (
139+ throw createCustomError (
139140 `Please provide either 'privateKey', 'mnemonic', or 'encryptedJson' & 'password' to import a wallet.` ,
141+ StatusCodes . BAD_REQUEST ,
142+ "MISSING_PARAMETERS" ,
140143 ) ;
141144 }
142145 break ;
143146 case WalletType . awsKms :
144147 const { awsKmsArn, awsKmsKeyId } = request . body as any ;
145148 if ( ! ( awsKmsArn && awsKmsKeyId ) ) {
146- throw new Error (
149+ throw createCustomError (
147150 `Please provide 'awsKmsArn' and 'awsKmsKeyId' to import a wallet.` ,
151+ StatusCodes . BAD_REQUEST ,
152+ "MISSING_PARAMETERS" ,
148153 ) ;
149154 }
150155
@@ -156,8 +161,10 @@ export const importBackendWallet = async (fastify: FastifyInstance) => {
156161 case WalletType . gcpKms :
157162 const { gcpKmsKeyId, gcpKmsKeyVersionId } = request . body as any ;
158163 if ( ! ( gcpKmsKeyId && gcpKmsKeyVersionId ) ) {
159- throw new Error (
164+ throw createCustomError (
160165 `Please provide 'gcpKmsKeyId' and 'gcpKmsKeyVersionId' to import a wallet.` ,
166+ StatusCodes . BAD_REQUEST ,
167+ "MISSING_PARAMETERS" ,
161168 ) ;
162169 }
163170
0 commit comments