Book Image

Mastering Web Application Development with Express

By : Alexandru Vladutu
Book Image

Mastering Web Application Development with Express

By: Alexandru Vladutu

Overview of this book

Table of Contents (18 chapters)
Mastering Web Application Development with Express
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Improving stack traces


The error stack trace limit is set to 10 by default in Node (v8 actually). We can, however, modify that limit by overriding Error.stackTraceLimit.

We will create a sample application and see how to achieve that:

function a() { throw new Error('stop right there mister'); }
function b() { a(); }
function c() { b(); }
function d() { c(); }
function e() { d(); }
function f() { e(); }
function g() { f(); }
function h() { g(); }
function i() { h(); }
function j() { i(); }
function k() { j(); }
function l() { k(); }
function m() { l(); }
function n() { m(); }
function o() { n(); }
function p() { o(); }
function q() { p(); }

q();

The stack should look like the following code:

Error: stop right there mister
    at a (/Users/alexandruvladutu/www/improving-stacks.js:1:84)
    at b (/Users/alexandruvladutu/www/improving-stacks.js:2:16)
    at c (/Users/alexandruvladutu/www/improving-stacks.js:3:16)
    at d (/Users/alexandruvladutu/www/improving-stacks.js:4:16)
    at e (/Users/alexandruvladutu...