From 1100ea168d1e320808318eac080059f50c1eb748 Mon Sep 17 00:00:00 2001 From: Niels V Date: Mon, 6 Jun 2022 15:54:25 +0200 Subject: [PATCH 1/3] improve error reporting if preview of notulen fails --- app/controllers/meetings/publish/notulen.js | 27 +++++++++++++-------- app/services/publish.js | 5 ++-- app/templates/meetings/publish/notulen.hbs | 9 +++++-- translations/en-us.yaml | 1 + translations/nl-BE.yaml | 1 + 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/app/controllers/meetings/publish/notulen.js b/app/controllers/meetings/publish/notulen.js index a0eb5a8d0..b954bac73 100644 --- a/app/controllers/meetings/publish/notulen.js +++ b/app/controllers/meetings/publish/notulen.js @@ -12,6 +12,7 @@ export default class MeetingsPublishNotulenController extends Controller { behandelingContainerId = 'behandeling-van-agendapunten-container'; @tracked notulen; @tracked errors; + @tracked validationErrors; @tracked signedResources = []; @tracked publishedResource; @tracked publicBehandelingUris = []; @@ -28,6 +29,7 @@ export default class MeetingsPublishNotulenController extends Controller { resetController() { this.notulen = null; this.errors = null; + this.validationErrors = null; this.signedResources = []; this.publishedResource = null; this.publicBehandelingUris = []; @@ -84,16 +86,21 @@ export default class MeetingsPublishNotulenController extends Controller { }) ); } else { - const { content, errors } = - yield this.createPrePublishedResource.perform(); - const rslt = yield this.store.createRecord('versioned-notulen', { - zitting: this.model, - content: content, - }); - this.publishedResource = undefined; - this.signedResources = []; - this.notulen = rslt; - this.errors = errors; + try { + const { content, errors } = yield this.createPrePublishedResource.perform(); + const rslt = yield this.store.createRecord('versioned-notulen', { + zitting: this.model, + content: content, + }); + this.publishedResource = undefined; + this.signedResources = []; + this.notulen = rslt; + this.validationErrors = errors; + } + catch(e) { + console.error(e); + this.errors = [e]; + } } if (this.status !== 'published') { const treatments = yield this.fetchTreatments.perform(); diff --git a/app/services/publish.js b/app/services/publish.js index 364323ec5..263245077 100644 --- a/app/services/publish.js +++ b/app/services/publish.js @@ -88,14 +88,15 @@ export default class PublishService extends Service { } while (resp.status === 404 && maxIterations > 0); if (resp.status !== 200) { - let errors = yield resp.text(); + let errors; try { const json = yield resp.json(); if (json?.errors) { - errors = JSON.stringify(json.errors); + errors = json.errors[0]?.title || JSON.stringify(json.errors); } } catch (e) { // throwing body text + errors = yield resp.text(); throw new Error(errors); } // throwing stringified json body diff --git a/app/templates/meetings/publish/notulen.hbs b/app/templates/meetings/publish/notulen.hbs index 2dc83892a..4d14a29da 100644 --- a/app/templates/meetings/publish/notulen.hbs +++ b/app/templates/meetings/publish/notulen.hbs @@ -30,14 +30,19 @@ {{/in-element}} {{/if}} - {{#if (and this.errors this.errors.length)}} + {{#if (and this.validationErrors this.validationErrors.length)}} + {{else if (and this.errors this.errors.length)}} + +

{{t 'publish.seriousError'}}

+ {{this.errors.firstObject}} +
{{else}} {{!-- Sign --}} Date: Mon, 6 Jun 2022 15:58:08 +0200 Subject: [PATCH 2/3] use correct email address --- translations/en-us.yaml | 2 +- translations/nl-BE.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/translations/en-us.yaml b/translations/en-us.yaml index 683a116e1..384cef9a5 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -59,7 +59,7 @@ publish: excerptErrorMessage: Something went wrong fetching the excerpt. publishButtonLabel: Sign and publish toggleAllPublicLabel: Toggle all public - seriousError: An error occured, please try again at a later time. If the error persists please contact gelinkt-notuleren@vlaanderen.be and include the information below. + seriousError: An error occured, please try again at a later time. If the error persists please contact GelinktNotuleren and include the information below. behandelingVanAgendapunten: documentLink: "document link" saveButton: Save diff --git a/translations/nl-BE.yaml b/translations/nl-BE.yaml index 36cdd3fc6..b3ace8746 100644 --- a/translations/nl-BE.yaml +++ b/translations/nl-BE.yaml @@ -59,7 +59,7 @@ publish: agendapoint: Agendapunt publishButtonLabel: Onderteken en publiceer toggleAllPublicLabel: Maak de inhoud van alle agendapunten publiek - seriousError: Er heeft zich een fout voorgedaan, gelieve op een later tijdstip nogmaals te proberen. Als de fout aanhoudt contacteer gelinkt-notuleren@vlaanderen.be met onderstaande informatie. + seriousError: Er heeft zich een fout voorgedaan, gelieve op een later tijdstip nogmaals te proberen. Als de fout aanhoudt contacteer GelinktNotuleren@vlaanderen.be met onderstaande informatie. behandelingVanAgendapunten: documentLink: "document link" saveButton: Opslaan From adad9737cf1e83d72472102dd49f6dc8e7ce0566 Mon Sep 17 00:00:00 2001 From: Niels Vandekeybus Date: Wed, 8 Jun 2022 13:23:16 +0200 Subject: [PATCH 3/3] linting --- app/controllers/meetings/publish/notulen.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/meetings/publish/notulen.js b/app/controllers/meetings/publish/notulen.js index b954bac73..055158a28 100644 --- a/app/controllers/meetings/publish/notulen.js +++ b/app/controllers/meetings/publish/notulen.js @@ -87,7 +87,8 @@ export default class MeetingsPublishNotulenController extends Controller { ); } else { try { - const { content, errors } = yield this.createPrePublishedResource.perform(); + const { content, errors } = + yield this.createPrePublishedResource.perform(); const rslt = yield this.store.createRecord('versioned-notulen', { zitting: this.model, content: content, @@ -96,8 +97,7 @@ export default class MeetingsPublishNotulenController extends Controller { this.signedResources = []; this.notulen = rslt; this.validationErrors = errors; - } - catch(e) { + } catch (e) { console.error(e); this.errors = [e]; }