question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Express EJS Layout intercept error

See original GitHub issue

Hello,

I have a strange issue, it seems that each time there is an error in my app (wherever it is), the plugin intercepts the error and print out something really not helping.

It is exactly as this stack overflow question: http://stackoverflow.com/questions/25433238/express-layouts-error-variable-not-defined

Comment say: express-ejs-layouts drives me crazy with this. If anything goes wrong in the controller or view, it reports that the first variable referenced in the view or layout is undefined. Basically I can never trust the error messages I get when using express-ejs-layouts.

And this is exactly the issue I have. It is really hard to debug the app because of that…

Any idea?

Thanks 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
soarezcommented, Apr 22, 2017

There’s nothing wrong with express-ejs-layouts here.

The reason why you see “title is not defined” as the error is because that is the actual error.

Your app is catching the initial error and then rendering an error page, which also uses the layout, but you’re not defining res.locals.title = 'Some error title' in the error handler.

0reactions
soarezcommented, Apr 23, 2017

No worries Regis, happens to all of us 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error handling - Express.js
Error Handling refers to how Express catches and processes errors that occur both synchronously and asynchronously. Express comes with a default error ......
Read more >
express-ejs-layout sometimes fails to detect passing argument
I am rendering a page where I am passing data "userInfo" but sometimes it render and sometimes it shows this ReferenceError, not sure...
Read more >
Error handling in Node.js with Express - DEV Community ‍ ‍
Beside from the user experience, it is a good practice to catch errors in one place (all the errors go through the handler)...
Read more >
Best Practices for Node.js Error-handling - Toptal
This article will introduce you to error-handling in Node.js and ... Knowing the basics about handling errors in Express.js middleware would certainly help....
Read more >
Node.js v19.3.0 Documentation
Error propagation and interception. Error-first callbacks. Class: Error. new Error(message[, options]); Error.captureStackTrace(targetObject[ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found