throw error if there are no builds when rendering
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
f557a9eb26
commit
946156c257
|
@ -29,7 +29,9 @@ const App = (ghc) => {
|
||||||
body: ghc.db.schema,
|
body: ghc.db.schema,
|
||||||
},
|
},
|
||||||
handler: async (ctx) => {
|
handler: async (ctx) => {
|
||||||
|
/* save the build */
|
||||||
await ghc.db.addBuild(ctx.params.pr, ctx.request.body)
|
await ghc.db.addBuild(ctx.params.pr, ctx.request.body)
|
||||||
|
/* post or update the comment */
|
||||||
await ghc.update(ctx.params.pr)
|
await ghc.update(ctx.params.pr)
|
||||||
ctx.status = 201
|
ctx.status = 201
|
||||||
ctx.body = {status:'ok'}
|
ctx.body = {status:'ok'}
|
||||||
|
|
|
@ -20,6 +20,9 @@ class Comments {
|
||||||
|
|
||||||
async renderComment (pr) {
|
async renderComment (pr) {
|
||||||
const builds = await this.db.getBuilds(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})
|
return this.nj.renderString(this.template, {builds})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue