Reject promise if an exception occurs.

Related to #413