diff --git a/packages/cli/src/cmds/validator/keys.ts b/packages/cli/src/cmds/validator/keys.ts index 1967fe8c20eb..6f8a4b8e94b0 100644 --- a/packages/cli/src/cmds/validator/keys.ts +++ b/packages/cli/src/cmds/validator/keys.ts @@ -59,9 +59,19 @@ export async function getLocalSecretKeys( } const secretKeys = await Promise.all( - keystorePaths.map(async (keystorePath) => - SecretKey.fromBytes(await Keystore.parse(fs.readFileSync(keystorePath, "utf8")).decrypt(passphrase)) - ) + keystorePaths.map(async (keystorePath) => { + const keystoreStr = fs.readFileSync(keystorePath, "utf8"); + + let keystore; + try { + keystore = Keystore.parse(keystoreStr); + } catch (e) { + (e as Error).message = `Error parsing keystore at ${keystorePath}: ${(e as Error).message}`; + throw e; + } + + return SecretKey.fromBytes(await keystore.decrypt(passphrase)); + }) ); return {