madoos / fp-error-trace

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NPM version Build Status Dependency Status Coverage percentage

fp-error-trace

Small helper that show errors produced in function compositions.

Getting Started

To install:

npm i -S fp-error-trace

Trace a function:

const trace = require('fp-error-trace')
const R = require('ramda')
const pipe = trace(R.pipe)

const plus = add(1)
const unexpectedError = () => { throw new Error('some error')}

const triplePlus = pipe(
    unexpectedError
    plus, 
    plus, 
    plus
)

// in console: Error occurred in pipe at argument 1 (/your/file.js:3:18)

Trace all library:

const trace = require('fp-error-trace')
const {compose, add} = trace.all(require('ramda'))

const plus = add(1)
const unexpectedError = () => { throw new Error('some error')}

const triplePlus = compose(
    plus, 
    plus, 
    plus, 
    unexpectedError
)

// in console: Error occurred in compose at argument 4 (/your/file.js:3:18)

License

MIT © Maurice Domínguez

About

License:MIT License


Languages

Language:JavaScript 100.0%