From 946156c257b1c50df2651f9f6e294f5cc2c4a2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 13 Dec 2018 12:50:47 +0100 Subject: [PATCH] throw error if there are no builds when rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- src/app.js | 2 ++ src/comments.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/app.js b/src/app.js index 02c644f..bebb32f 100644 --- a/src/app.js +++ b/src/app.js @@ -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'} diff --git a/src/comments.js b/src/comments.js index 3e7e160..a15f5d0 100644 --- a/src/comments.js +++ b/src/comments.js @@ -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}) }