primate 0.21.1 → 0.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primate",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "description": "Expressive, minimal and extensible web framework",
5
5
  "homepage": "https://primatejs.com",
6
6
  "bugs": "https://github.com/primatejs/primate/issues",
package/src/app.js CHANGED
@@ -169,10 +169,14 @@ export default async (config, root, log) => {
169
169
  dispatch: dispatch(types),
170
170
  };
171
171
 
172
+ const error = await app.paths.routes.join("+error.js");
172
173
  const modules = await loaders.modules(app, root, config);
173
174
 
174
175
  return {...app,
175
176
  modules,
177
+ error: {
178
+ default: await error.exists ? (await import(error)).default : undefined,
179
+ },
176
180
  layoutDepth: Math.max(...app.routes.map(({layouts}) => layouts.length)) + 1,
177
181
  route: hooks.route({...app, modules}),
178
182
  parse: hooks.parse(dispatch(types)),
@@ -14,7 +14,7 @@ export default app => {
14
14
  const route = async request => {
15
15
  const {pathname} = request.url;
16
16
  // if NoFileForPath is thrown, this will remain undefined
17
- let errorHandler = undefined;
17
+ let errorHandler = app.error.default;
18
18
 
19
19
  return tryreturn(async _ => {
20
20
  const {path, guards, errors, layouts, handler} = invalid(pathname)
@@ -50,9 +50,9 @@ export default app => {
50
50
  }, request);
51
51
  }).orelse(async error => {
52
52
  app.log.auto(error);
53
- console.log("HI")
53
+
54
54
  // the +error.js page itself could fail
55
- return tryreturn(_ => respond(errorHandler())(app, {}, request))
55
+ return tryreturn(_ => respond(errorHandler(request))(app, {}, request))
56
56
  .orelse(_ => clientError()(app, {}, request));
57
57
  });
58
58
  };