Skip to content

Instantly share code, notes, and snippets.

@ktilcu
Last active October 18, 2017 17:46
Show Gist options
  • Select an option

  • Save ktilcu/dcc39f01c45d4c07f0b0c3e92d500aa8 to your computer and use it in GitHub Desktop.

Select an option

Save ktilcu/dcc39f01c45d4c07f0b0c3e92d500aa8 to your computer and use it in GitHub Desktop.
Context Logging
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