throw error if there are no builds when rendering

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2018-12-13 12:50:47 +01:00
parent f557a9eb26
commit 946156c257
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 5 additions and 0 deletions

View File

@ -29,7 +29,9 @@ const App = (ghc) => {
body: ghc.db.schema,
},
handler: async (ctx) => {
/* save the build */
await ghc.db.addBuild(ctx.params.pr, ctx.request.body)
/* post or update the comment */
await ghc.update(ctx.params.pr)
ctx.status = 201
ctx.body = {status:'ok'}

View File

@ -20,6 +20,9 @@ class Comments {
async renderComment (pr) {
const builds = await this.db.getBuilds(pr)
if (builds.length == 0) {
throw Error('No builds exist for this PR')
}
return this.nj.renderString(this.template, {builds})
}