mirror of
https://github.com/janoside/btc-rpc-explorer.git
synced 2026-08-13 12:33:13 +02:00
better 404 handling; /address: fix catch issue
This commit is contained in:
parent
54eae151dc
commit
ee77a79736
2 changed files with 14 additions and 3 deletions
15
app.js
15
app.js
|
|
@ -846,12 +846,23 @@ expressApp.use(function(req, res, next) {
|
|||
|
||||
/// error handlers
|
||||
|
||||
const sharedErrorHandler = (err) => {
|
||||
if (err && err.message && err.message.includes("Not Found")) {
|
||||
const path = err.toString().substring(err.toString().lastIndexOf(" ") + 1);
|
||||
|
||||
utils.logError(`NotFound-${path}`, err);
|
||||
|
||||
} else {
|
||||
utils.logError("ExpressUncaughtError", err);
|
||||
}
|
||||
};
|
||||
|
||||
// development error handler
|
||||
// will print stacktrace
|
||||
if (expressApp.get("env") === "development" || expressApp.get("env") === "local") {
|
||||
expressApp.use(function(err, req, res, next) {
|
||||
if (err) {
|
||||
utils.logError("3289023yege", err);
|
||||
sharedErrorHandler(err);
|
||||
}
|
||||
|
||||
res.status(err.status || 500);
|
||||
|
|
@ -866,7 +877,7 @@ if (expressApp.get("env") === "development" || expressApp.get("env") === "local"
|
|||
// no stacktraces leaked to user
|
||||
expressApp.use(function(err, req, res, next) {
|
||||
if (err) {
|
||||
utils.logError("2309832hcxwgeeew", err);
|
||||
sharedErrorHandler(err);
|
||||
}
|
||||
|
||||
res.status(err.status || 500);
|
||||
|
|
|
|||
|
|
@ -1644,7 +1644,7 @@ router.get("/address/:address", asyncHandler(async (req, res, next) => {
|
|||
next();
|
||||
|
||||
} catch (e) {
|
||||
res.locals.pageErrors.push(utils.logError("2108hs0gsdfe", err, {address:address}));
|
||||
res.locals.pageErrors.push(utils.logError("2108hs0gsdfe", e, {address:address}));
|
||||
|
||||
res.locals.userMessageMarkdown = `Failed to load address: **${address}**`;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue