Skip to content

Instantly share code, notes, and snippets.

@julianduque
Created June 2, 2016 01:07
Show Gist options
  • Save julianduque/fe339d0696c2ee3c852cff46ca23c9f5 to your computer and use it in GitHub Desktop.
Save julianduque/fe339d0696c2ee3c852cff46ca23c9f5 to your computer and use it in GitHub Desktop.
> var a = () => { throw new Error() }
undefined
> a() // arrow function is named (as function statement)
Error
    at a (repl:1:23) // we know the error happened at function a
    at repl:1:1
    at REPLServer.defaultEval (repl.js:265:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:434:12)
    at emitOne (events.js:82:20)
    at REPLServer.emit (events.js:169:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
    at REPLServer.Interface._line (readline.js:550:8)
> var a = function (cb) { cb() }
undefined
> a(function () { throw new Error() }) // anonymous function isn't named
Error
    at repl:1:23 // we don't know where the error happened
    at a (repl:1:25)
    at repl:1:1
    at REPLServer.defaultEval (repl.js:265:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:434:12)
    at emitOne (events.js:82:20)
    at REPLServer.emit (events.js:169:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
> a(function throwAndError() { throw new Error() }) // we named the function
Error
    at throwAndError (repl:1:36) // we know where the error happened (throwAndError)
    at a (repl:1:25)
    at repl:1:1
    at REPLServer.defaultEval (repl.js:265:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:434:12)
    at emitOne (events.js:82:20)
    at REPLServer.emit (events.js:169:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
> a(() => { throw new Error() }) // arrow functions doesn't have a name (unless they are statements)
Error
    at repl:1:17 // we don't know what function crashed
    at a (repl:1:25)
    at repl:1:1
    at REPLServer.defaultEval (repl.js:265:27)
    at bound (domain.js:287:14)
    at REPLServer.runBound [as eval] (domain.js:300:12)
    at REPLServer.<anonymous> (repl.js:434:12)
    at emitOne (events.js:82:20)
    at REPLServer.emit (events.js:169:7)
    at REPLServer.Interface._onLine (readline.js:211:10)
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment