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 +1 -1
- package/src/app.js +4 -0
- package/src/hooks/handle.js +3 -3
package/package.json
CHANGED
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)),
|
package/src/hooks/handle.js
CHANGED
|
@@ -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 =
|
|
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
|
-
|
|
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
|
};
|