UBServerReport.js - provide developer friendly messages if try to makeReport with incorrect report code (report does not exist)
This code inside UBServerReport.js
generates error on server, if code is not correct:
let reportInfo = UB.Repository('ubs_report')
.attrs(['ID', 'report_code', 'name', 'template', 'code', 'model'])
.where('[report_code]', '=', this.reportCode)
.selectSingle()
And this line later is never called:
if (!reportInfo) throw new Error(`Report with code "${this.reportCode}" not found`)
All that is because of the sophisticated caching logic in the entity, which does not work as expected and does not return undefined, if report not found, but instead craches:
TubDataStore.initialize@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\ub\TubDataStore.js:155:11
doSelect@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\ubs\ubs_report.js:177:3
me.select@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\ubs\ubs_report.js:191:3
selectAsObject@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\base\ServerRepository.js:64:7
selectSingle@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\base\ServerRepository.js:141:12
UBServerReport.prototype.init@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\ubs\modules\UBServerReport.js:116:20
UBServerReport.prototype.makeReport@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\ubs\modules\UBServerReport.js:176:3
module.exports.makeReport@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\ubs\modules\UBServerReport.js:33:12
buildReportAndAddMailToQueue@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\bpm\modules\mailUtils.js:26:18
parseAndExecute@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\bpm-camunda\modules\extTasks\emailJob.js:32:5
run/<@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\bpm-camunda\modules\extTasks\emailJob.js:80:7
run@C:\Users\rumata\Work\nectain\ub-app\node_modules\@unitybase\bpm-camunda\modules\extTasks\emailJob.js:76:3
...