Last active
October 18, 2017 17:46
-
-
Save ktilcu/dcc39f01c45d4c07f0b0c3e92d500aa8 to your computer and use it in GitHub Desktop.
Context Logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const contextLogger = fn => ([...args]) => | |
| fn | |
| .apply(null, args) | |
| .catch(err => { | |
| console.log({args, err}); | |
| return Promise.reject(err); | |
| }); | |
| const makeRequest = () => { | |
| contextLogger(getJSON)() // weird i know but I'm doing this without curry. | |
| .then(contextLogger(JSON.parse)) | |
| .then(console.log) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment