Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Error.captureStackTrace to create the stack property #27

Merged
merged 1 commit into from
Aug 23, 2016

Conversation

lpinca
Copy link
Contributor

@lpinca lpinca commented Aug 19, 2016

When subclassing Error in Node.js it is a good practice to use Error.captureStackTrace to create the stack property. See the following example:

'use strict';

const FigoError = require('./lib/errors').FigoError;

const err = new FigoError('foo', 'bar');

console.log(err.stack);

Before this patch:

Error
    at new FigoError (/Users/luigi/repos/node-figo/lib/errors.js:14:17)
    at Object.<anonymous> (/Users/luigi/repos/node-figo/throw.js:5:13)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (bootstrap_node.js:352:7)
    at startup (bootstrap_node.js:144:9)

After this patch:

FigoError: bar
    at Object.<anonymous> (/Users/luigi/repos/node-figo/throw.js:5:13)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.runMain (module.js:575:10)
    at run (bootstrap_node.js:352:7)
    at startup (bootstrap_node.js:144:9)
    at bootstrap_node.js:467:3

@mfilenko mfilenko merged commit 7f19f17 into figo-connect:master Aug 23, 2016
@lpinca lpinca deleted the fix/error-stack branch August 23, 2016 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants