GithubHelp home page GithubHelp logo

nickuraltsev / composite-error Goto Github PK

View Code? Open in Web Editor NEW
12.0 12.0 0.0 14 KB

Error wrapping in Node.js

License: MIT License

JavaScript 100.00%
error-handling error-wrapping errors inner-errors stack-traces

composite-error's People

Contributors

nickuraltsev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

composite-error's Issues

Getting "TypeError: Cannot read property 'call' of undefined" when trying to print to console

I'm getting TypeError: Cannot read property 'call' of undefined when trying to use this module and printing to console. For example, following the example given in the module:

const firstError = new Error('First error');
const secondError = new CompositeError('Second error', firstError);
const thirdError = new CompositeError('Third error', secondError);

console.log(thirdError.stack);

Prints the following:

TypeError: Cannot read property 'call' of undefined
    at CompositeError.get (C:\dev\csp2\frontend\src\csp2\commands\node_modules\composite-error\lib\compositeError.js:44:44)
    at CompositeError.formatStackTraces (C:\dev\csp2\frontend\src\csp2\commands\node_modules\composite-error\lib\compositeError.js:55:20)
    at CompositeError.get (C:\dev\csp2\frontend\src\csp2\commands\node_modules\composite-error\lib\compositeError.js:24:35)
    at repl:1:23
    at ContextifyScript.Script.runInThisContext (vm.js:23:33)
    at REPLServer.defaultEval (repl.js:340:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.onLine (repl.js:537:10)
    at emitOne (events.js:101:20)

My environment:

OS: Windows 10 Pro 64-bit 14393.953
Node: v7.8.0
NPM: v4.2.0

stack value has undefined for values.

After creating a composite error, the result is that innerErrors contains the string messages for all the expected errors.

[
      "Term (1.0_15571108706641871406552) referenced in relationship (represent-element) cannot be found.",
      "Term (1.0_15571108235121756500925) referenced in relationship (represent-element) cannot be found.",
      "Term (1.0_1557110627098-1963619659) referenced in relationship (represent-element) cannot be found.",
      "Term (1.0_1557110802238-1919010934) referenced in relationship (represent-element) cannot be found.",
      "Term (1.0_15571108133752086874573) referenced in relationship (represent-element) cannot be found."
]

However, the stack contains undefined for all the steps:

"CompositeError: One or more errors occurred while setting up terminology relatonships from MDR
    at Object.refreshTerminologyFromMdr (C:\Code\ncp\study-design-service\src\mdr-service.js:212:11)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async refreshMdrCache (C:\Code\ncp\study-design-service\index.js:70:5)
--- Inner error #0: undefined
--- End of inner error
--- Inner error #1: undefined
--- End of inner error
--- Inner error #2: undefined
--- End of inner error
--- Inner error #3: undefined
--- End of inner error
--- Inner error #4: undefined
--- End of inner error"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.