Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
add helpful error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hennessyevan committed Sep 13, 2019
1 parent bc167d6 commit df31b62
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/tasks/createDocsFromData.ts
Expand Up @@ -15,11 +15,13 @@ export async function createDocsFromData(ctx: ListrContext, task: ListrTaskWrapp
task.report(error)
})
)
await pEachSeries(mongoosePromises, () => {}).catch(err => task.report(err))
await pEachSeries(mongoosePromises, () => {}).catch(err =>
task.report({ ...err, message: `${err.message} at Mongoose` })
)
return modelName
})
await pEachSeries(creationPromises, model => (task.output = model)).catch(err =>
task.report(err)
task.report({ ...err, message: `${err.message} at Document Creation` })
)
}
}
2 changes: 1 addition & 1 deletion src/tasks/generate.ts
Expand Up @@ -17,5 +17,5 @@ export async function generate(ctx: ListrContext, task: ListrTaskWrapper) {
})
await pEachSeries(generationPromises, model => {
task.output = model
}).catch(err => log(err, LogType.error))
}).catch(err => task.report({ ...err, message: `${err.message} at Data Generation` }))
}
4 changes: 2 additions & 2 deletions src/tasks/loadModels.ts
Expand Up @@ -8,7 +8,7 @@ import pEachSeries from "p-each-series"
export async function loadModels(ctx: ListrContext, task: ListrTaskWrapper) {
ctx.models = await getModels(ctx.config.modelDir)
// Connect mongoose
await mongoose.connect(ctx.config.mongoURI, { useNewUrlParser: true })
await mongoose.connect(ctx.config.mongoURI, { useNewUrlParser: true, useUnifiedTopology: true })
await mongoose.connection.dropDatabase()

const modelPromises = ctx.models.map(async model => {
Expand All @@ -19,5 +19,5 @@ export async function loadModels(ctx: ListrContext, task: ListrTaskWrapper) {

await pEachSeries(modelPromises, model => {
task.output = model
}).catch(err => task.report(err))
}).catch(err => task.report({ ...err, message: `${err.message} at Model Loading` }))
}
4 changes: 3 additions & 1 deletion src/tasks/populate.ts
Expand Up @@ -23,5 +23,7 @@ export async function populate(ctx: ListrContext, task: ListrTaskWrapper) {
})
})

await pEachSeries(populationPromises, () => {}).catch(err => task.report(err))
await pEachSeries(populationPromises, () => {}).catch(err =>
task.report({ ...err, message: `${err.message} at SmartID Population` })
)
}

0 comments on commit df31b62

Please sign in to comment.