Fix error handling
This commit is contained in:
parent
de88321865
commit
f90bcfe27b
1 changed files with 7 additions and 7 deletions
|
@ -47,15 +47,15 @@ AngelConfigurer configureServer(FileSystem fileSystem) {
|
||||||
|
|
||||||
var oldErrorHandler = app.errorHandler;
|
var oldErrorHandler = app.errorHandler;
|
||||||
app.errorHandler = (e, req, res) async {
|
app.errorHandler = (e, req, res) async {
|
||||||
if (!req.accepts('text/html', strict: true))
|
if (req.accepts('text/html', strict: true)) {
|
||||||
return await oldErrorHandler(e, req, res);
|
if (e.statusCode == 404 && req.accepts('text/html', strict: true)) {
|
||||||
else {
|
await res
|
||||||
if (e.statusCode == 404) {
|
|
||||||
return await res
|
|
||||||
.render('error', {'message': 'No file exists at ${req.uri}.'});
|
.render('error', {'message': 'No file exists at ${req.uri}.'});
|
||||||
|
} else {
|
||||||
|
await res.render('error', {'message': e.message});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
return await res.render('error', {'message': e.message});
|
return await oldErrorHandler(e, req, res);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue