Fixed unhandled rejection error and added more logs

This commit is contained in:
emad-salah 2019-12-08 19:06:43 +01:00
parent 1896353ff3
commit a6d499bcbb

View file

@ -328,6 +328,7 @@ module.exports = (
}); });
app.post("/api/lnd/wallet", async (req, res) => { app.post("/api/lnd/wallet", async (req, res) => {
try {
const { password, alias } = req.body; const { password, alias } = req.body;
const healthResponse = await checkHealth(); const healthResponse = await checkHealth();
if (!alias) { if (!alias) {
@ -359,6 +360,7 @@ module.exports = (
} }
walletUnlocker.genSeed({}, async (genSeedErr, genSeedResponse) => { walletUnlocker.genSeed({}, async (genSeedErr, genSeedResponse) => {
try {
if (genSeedErr) { if (genSeedErr) {
logger.debug("GenSeed Error:", genSeedErr); logger.debug("GenSeed Error:", genSeedErr);
@ -367,7 +369,7 @@ module.exports = (
const message = genSeedErr.details; const message = genSeedErr.details;
return res return res
.status(400) .status(400)
.send({ field: "GenSeed", errorMessage, success: false }); .send({ field: "GenSeed", errorMessage: message, success: false });
} }
return res return res
@ -388,6 +390,7 @@ module.exports = (
walletUnlocker.initWallet( walletUnlocker.initWallet(
walletArgs, walletArgs,
async (initWalletErr, initWalletResponse) => { async (initWalletErr, initWalletResponse) => {
try {
if (initWalletErr) { if (initWalletErr) {
logger.error("initWallet Error:", initWalletErr.message); logger.error("initWallet Error:", initWalletErr.message);
const healthResponse = await checkHealth(); const healthResponse = await checkHealth();
@ -451,9 +454,30 @@ module.exports = (
}; };
waitUntilFileExists(1); waitUntilFileExists(1);
} catch (err) {
console.error(err);
return res.status(500).json({
field: "unknown",
errorMessage: err
})
}
} }
); );
} catch (err) {
console.error(err);
return res.status(500).json({
field: "unknown",
errorMessage: err
})
}
}); });
} catch (err) {
console.error(err);
return res.status(500).json({
field: "unknown",
errorMessage: err
})
}
}); });
app.post("/api/lnd/wallet/existing", async (req, res) => { app.post("/api/lnd/wallet/existing", async (req, res) => {