Skip to content

Commit

Permalink
Merge pull request #280 from lblod/feature/better-error-reporting
Browse files Browse the repository at this point in the history
improve error reporting if preview of notulen fails
  • Loading branch information
nvdk authored Jun 16, 2022
2 parents 16e5fad + adad973 commit 6e4199f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
27 changes: 17 additions & 10 deletions app/controllers/meetings/publish/notulen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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 = [];
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions app/services/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions app/templates/meetings/publish/notulen.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@
{{/in-element}}
{{/if}}
</PublicationPreview>
{{#if (and this.errors this.errors.length)}}
{{#if (and this.validationErrors this.validationErrors.length)}}
<AuAlert @alertIcon="alert-triangle" @alertTitle={{t "timelineStep.publishWarning"}} @alertSkin="error">
<ul>
{{#each this.errors as |error|}}
{{#each this.validationErrors as |error|}}
<li>{{error}}</li>
{{/each}}
</ul>
</AuAlert>
{{else if (and this.errors this.errors.length)}}
<AuAlert @alertIcon="alert-triangle" @alertSkin="error">
<p>{{t 'publish.seriousError'}}</p>
<code>{{this.errors.firstObject}}</code>
</AuAlert>
{{else}}
{{!-- Sign --}}
<PublicationSignatures
Expand Down
1 change: 1 addition & 0 deletions translations/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,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 GelinktNotuleren and include the information below.
behandelingVanAgendapunten:
documentLink: "document link"
saveButton: Save
Expand Down
1 change: 1 addition & 0 deletions translations/nl-BE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,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 [email protected] met onderstaande informatie.
behandelingVanAgendapunten:
documentLink: "document link"
saveButton: Opslaan
Expand Down

0 comments on commit 6e4199f

Please sign in to comment.