Skip to content

Commit

Permalink
Merge pull request #797 from lblod/fix/handle-non-200
Browse files Browse the repository at this point in the history
Fix publish service to handle non-200 success status codes
  • Loading branch information
elpoelma authored Jan 2, 2025
2 parents e2f5414 + 4166e84 commit 42874e3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-eyes-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'frontend-gelinkt-notuleren': patch
---

Fix publish service to handle non-200 success status codes
2 changes: 1 addition & 1 deletion app/controllers/meetings/publish/besluitenlijst.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class MeetingsPublishBesluitenlijstController extends Controller
maxIterations--;
} while (resp.status === 404 && maxIterations > 0);

if (resp.status !== 200) {
if (!resp.ok) {
throw new Error(await resp.text());
} else {
return await resp.json();
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/meetings/publish/notulen.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ export default class MeetingsPublishNotulenController extends Controller {
const previewHtml = json.data.attributes.html;
this.preview = previewHtml;
} catch (e) {
console.error(e);
this.errors = [JSON.stringify(e)];
console.error('Error generating notulen preview', e);
this.errors = [e.message];
}
});

Expand Down
2 changes: 1 addition & 1 deletion app/services/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class PublishService extends Service {
maxIterations--;
} while (resp.status === 404 && maxIterations > 0);

if (resp.status !== 200) {
if (!resp.ok) {
let errors;
try {
const json = await resp.json();
Expand Down
6 changes: 3 additions & 3 deletions app/services/template-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class TemplateFetcher extends Service {
`;

const response = await this.sendQuery(sparqlEndpoint, sparqlQuery);
if (response.status === 200) {
if (!response.ok) {
const json = await response.json();
const bindings = json.results.bindings;
const templates = bindings.map(this.bindingToTemplate(fileEndpoint));
Expand Down Expand Up @@ -99,7 +99,7 @@ export default class TemplateFetcher extends Service {
`;

const response = await this.sendQuery(sparqlEndpoint, sparqlQuery);
if (response.status === 200) {
if (!response.ok) {
const json = await response.json();
const bindings = json.results.bindings;
const templates = bindings.map(this.bindingToTemplate(fileEndpoint));
Expand Down Expand Up @@ -145,7 +145,7 @@ export default class TemplateFetcher extends Service {
ORDER BY LCASE(REPLACE(STR(?title), '^ +| +$', ''))
`;
const response = await this.sendQuery(sparqlEndpoint, sparqlQuery);
if (response.status === 200) {
if (!response.ok) {
const json = await response.json();
const bindings = json.results.bindings;
const templates = bindings.map(this.bindingToTemplate(fileEndpoint));
Expand Down

0 comments on commit 42874e3

Please sign in to comment.