bluebird: more strict .catch definitions

This commit is contained in:
Artur Eshenbrener
2016-10-05 12:58:41 +03:00
parent b26b960488
commit 5724f1fe4d
2 changed files with 20 additions and 4 deletions

View File

@@ -338,6 +338,17 @@ fooOrBarProm = fooProm.caught(Promise.CancellationError, (reason: any) => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{
class CustomError extends Error {
public customField: number;
}
fooProm = fooProm.catch(CustomError, reason => {
let a: number = reason.customField
})
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.error((reason: any) => {
return bar;
});

View File

@@ -71,14 +71,19 @@ class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R> {
*/
catch(predicate: (error: any) => boolean, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught(predicate: (error: any) => boolean, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch(ErrorClass: Function, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught(ErrorClass: Function, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<U>(ErrorClass: Function, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<U>(ErrorClass: Function, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch<E>(ErrorClass: new () => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught<E>(ErrorClass: new () => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<E, U>(ErrorClass: new () => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<E, U>(ErrorClass: new () => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<U>(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<U>(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;