Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit 8ee506b

Browse files
committed
foutmelding wanneer id niet bestaat
1 parent 5740613 commit 8ee506b

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/controllers/PageController.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@ export async function usePageOfSource(req, res) {
33
const sourceMap = res.locals.sourceMap;
44
const path = "/" + req.params[0];
55

6-
if(sourceMap.has(path)) {
6+
if (sourceMap.has(path)) {
77
const source = sourceMap.get(path);
88

99
const id = req.params.id;
1010
const page = await source.getPage(id);
11+
if (page == null) {
12+
res.status(404).send(`The page with this ID does not exist`);
13+
} else {
1114

12-
const s = await page.getSerializedPage('text/turtle');
13-
s.pipe(res);
15+
const s = await page.getSerializedPage('text/turtle');
16+
s.pipe(res);
17+
}
1418
}
1519
else {
1620
//console.error(`The endpoint ${path} does not exist`)
17-
res.status(404).send(`The endpoint ${path} does not exist`)
21+
res.status(404).send(`The endpoint ${path} does not exist`);
1822
}
19-
23+
2024
}

src/lib/Source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export abstract class Source implements ISource {
2828
//rejectOnEmpty: true,
2929
});
3030
if (response == null) {
31-
return new Page([], []);
31+
return null;
3232
}
3333
let parsed = JSON.parse(response.page);
3434
let page_ = this.deserializePage(parsed);

0 commit comments

Comments
 (0)