From 490837a5e1749fa7ab30e7b397728cd40aebead3 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Fri, 7 Jan 2022 12:22:40 +0530 Subject: [PATCH] fix: remove unnecessary try-catch --- index.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 7c522ea6..9ec09088 100644 --- a/index.js +++ b/index.js @@ -20,10 +20,8 @@ module.exports = { currency ??= 'XXX'; // to be called after db initialization - let values; - try { - // error thrown if migration hasn't taken place - values = await frappe.db.getSingleValues( + const values = + (await frappe.db?.getSingleValues( { fieldname: 'internalPrecision', parent: 'SystemSettings', @@ -32,10 +30,7 @@ module.exports = { fieldname: 'displayPrecision', parent: 'SystemSettings', } - ); - } catch { - values = []; - } + )) ?? []; let { internalPrecision: precision, displayPrecision: display } = values.reduce((acc, { fieldname, value }) => { @@ -47,7 +42,7 @@ module.exports = { precision = DEFAULT_INTERNAL_PRECISION; } - if (typeof precision.value === 'string') { + if (typeof precision === 'string') { precision = parseInt(precision); }