Skip to content

staab/succinct-async

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This is a tiny library for adding custom trace data to error objects for easier debugging. Read the blog post.

npm version

Example:

class Thing {
  something() {
    throw new Error("Oops")
  }
  async somethingElse(cb) {
    this.something(await fetch('/'))
  }
}

instrumentObject(Thing.prototype)

const doStuff = instrument('doStuff', async () => {
  const thing = new Thing()

  await thing.somethingElse()
})

doStuff()

/*
Uncaught (in promise) Error: Oops
    at Thing.something (<anonymous>:3:11)
    at Thing.wrapper (<anonymous>:11:18)
    at Thing.somethingElse (<anonymous>:6:10)
    at async <anonymous>:15:3

 Intercepted in:
	 Thing.something
	 Thing.somethingElse
	 doStuff
*/

About

A tiny library to help you locate errors in heavily asynchronous javascript code, with no noise.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published