Bluebird sandbox

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.0.5/bluebird.js"></script>

JavaScript

var Bluebird = Promise.noConflict()

class MyError extends Error {}

const nativeAsync = async() => {
  throw new MyError();
}

const bluebirdAsync = Bluebird.method(async() => {
  throw new MyError();
})

nativeAsync()
  .then(a => console.log(a))
  .catch((e) => {
    if (e instanceof MyError) {
      return console.log("MyError detected!");
    }
    // Otherwise, if not matched, rethrow error
    throw e;
  })

bluebirdAsync()
	.then(a => console.log(a))
  .catch(MyError, () => console.log("MyError matched!"))
  // No need to rethrow error, if error not matched will ignore catch