diff --git a/src/targets/services/onOperationOrBillCreate.js b/src/targets/services/onOperationOrBillCreate.js index 9d10f854d8..a5e406e2f5 100644 --- a/src/targets/services/onOperationOrBillCreate.js +++ b/src/targets/services/onOperationOrBillCreate.js @@ -34,11 +34,22 @@ const onOperationOrBillCreate = async (client, options) => { // may be missed by `TransactionGreater` because their `_rev` don't start with `1` const notifLastSeq = setting.notifications.lastSeq log('info', '⌛ Fetching transaction changes...') - const notifChanges = await fetchChangesOrAll( - client, - TRANSACTION_DOCTYPE, - notifLastSeq - ) + let notifChanges + try { + notifChanges = await fetchChangesOrAll( + client, + TRANSACTION_DOCTYPE, + notifLastSeq + ) + } catch (e) { + if (!/Database does not exist/.test(e)) { + throw e + } else { + log('info', 'No transaction database so early exit') + process.exit(0) + } + } + log('info', '✅ Transaction changes fetched') const brands = await makeBrands(client, undefined, true) diff --git a/src/targets/services/onOperationOrBillCreateHelpers.js b/src/targets/services/onOperationOrBillCreateHelpers.js index 66a7858472..2a2ffaa5d3 100644 --- a/src/targets/services/onOperationOrBillCreateHelpers.js +++ b/src/targets/services/onOperationOrBillCreateHelpers.js @@ -56,8 +56,12 @@ export const doBillsMatching = async ( logResult(result) } } catch (e) { - log('error', `❗ [Bills matching service] ${e}`) - throw e + if (!/Database does not exist/.test(e)) { + log('error', `❗ [Bills matching service] ${e}`) + throw e + } else { + log('info', `⚠️ [Bills matching no database]`) + } } } @@ -104,8 +108,12 @@ export const doTransactionsMatching = async ( logResult(result) } } catch (e) { - log('error', `❗ [Transactions matching service] ${e}`) - throw e + if (!/Database does not exist/.test(e)) { + log('error', `❗ [Transactions matching service] ${e}`) + throw e + } else { + log('info', `⚠️ [Transactions matching service no database]`) + } } }