Will FP ever have a great Stack Trace story in JS?

Jason Kuhrt jasonkuhrt at me.com
Thu Sep 17 00:15:54 UTC 2015


For example, today, a stone from the bedrock of FP:

> ```
> let compose = (b, a) => (...as) => b(a(...as))
> ```

will cause a JS Stack Trace to go from something useful (space around useful line) like:

> ```

> Error: Invariant Violation: createClass(...): Class specification must implement a `render` method.

>     at invariant (/Users/jasonkuhrt/code/test/node_modules/react/lib/invariant.js:42:15)

>     at ReactClass.createClass (/Users/jasonkuhrt/code/test/node_modules/react/lib/ReactClass.js:898:46)

> 

>     at componentFactory (/Users/jasonkuhrt/code/test/component-factory.js:1:36)

> 

>     at Object.<anonymous> (/Users/jasonkuhrt/code/test/test.js:4:1)
>     at Module._compile (module.js:460:26)
>     at normalLoader (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
>     at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7)
>     at Module.load (module.js:355:32)
>     at Function.Module._load (module.js:310:12)
>     at Function.Module.runMain (module.js:501:10)

> ```

To something much less useful like this:

> ```

> Error: Invariant Violation: createClass(...): Class specification must implement a `render` method.
>     at invariant (/Users/jasonkuhrt/code/test/node_modules/react/lib/invariant.js:42:15)
>     at ReactClass.createClass (/Users/jasonkuhrt/code/test/node_modules/react/lib/ReactClass.js:898:46)
> 
>     at /Users/jasonkuhrt/code/test/component-factory.js:4:41
> 
>     at Object.<anonymous> (/Users/jasonkuhrt/code/test/test.js:4:1)
>     at Module._compile (module.js:434:26)
>     at normalLoader (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
>     at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7)
>     at Module.load (module.js:355:32)
>     at Function.Module._load (module.js:310:12)
>     at Function.Module.runMain (module.js:475:10)

> ```

And ultimately being in a real-life scenario/library/etc. (e.g. Ramda compose) leading to something almost useless:

> ```

> Error: Invariant Violation: createClass(...): Class specification must implement a `render` method.
>     at invariant (/Users/jasonkuhrt/code/test/node_modules/react/lib/invariant.js:42:15)
>     at ReactClass.createClass (/Users/jasonkuhrt/code/test/node_modules/react/lib/ReactClass.js:898:46)
> 
>     at /Users/jasonkuhrt/code/test/node_modules/ramda/dist/ramda.js:384:35
>     at f1 (/Users/jasonkuhrt/code/test/node_modules/ramda/dist/ramda.js:156:27)
> 
>     at Object.<anonymous> (/Users/jasonkuhrt/code/test/test.js:4:1)
>     at Module._compile (module.js:434:26)
>     at normalLoader (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
>     at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7)
>     at Module.load (module.js:355:32)
>     at Function.Module._load (module.js:310:12)

> ```


More information about the es-discuss mailing list