added graceful error handling to getNewPrompt

This commit is contained in:
Andrzej Stepien 2023-08-10 17:33:51 +02:00
parent 3187a37483
commit 0f66d9a859
2 changed files with 7 additions and 2 deletions

View File

@ -21,6 +21,9 @@ export default async function getNewPrompt({ minCount = 200000, maxCount = 30000
.whereRaw('length(word) > 3') .whereRaw('length(word) > 3')
.whereNotNull('pronunciation') .whereNotNull('pronunciation')
.orderByRaw('count desc') .orderByRaw('count desc')
.catch(error=>{return error})
if(prompts instanceof Error){return prompts}
const getBiasedRng = (min, max, bias, influence) => { const getBiasedRng = (min, max, bias, influence) => {
const random = Math.random() * (max - min) + min const random = Math.random() * (max - min) + min
@ -44,7 +47,9 @@ export default async function getNewPrompt({ minCount = 200000, maxCount = 30000
console.dir(await getNewPrompt({}))
//console.dir(await getNewPrompt({}))
//console.log(await blocklist) //console.log(await blocklist)

View File

@ -55,7 +55,7 @@ export default async function insertPublished(res, word){
return res return res
}) })
.catch(error => { .catch(error => {
return error.message return error
}) })
} }