mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #14805 from Loghorn/add-catch-return-throw
Add catchReturn and catchThrow
This commit is contained in:
Vendored
+2
@@ -80,6 +80,8 @@ declare global {
|
||||
// then: typeof Bluebird.prototype.then;
|
||||
thenReturn: typeof Bluebird.prototype.thenReturn;
|
||||
thenThrow: typeof Bluebird.prototype.thenThrow;
|
||||
catchReturn: typeof Bluebird.prototype.catchReturn;
|
||||
catchThrow: typeof Bluebird.prototype.catchThrow;
|
||||
throw: typeof Bluebird.prototype.throw;
|
||||
timeout: typeof Bluebird.prototype.timeout;
|
||||
toJSON: typeof Bluebird.prototype.toJSON;
|
||||
|
||||
@@ -506,6 +506,15 @@ fooProm = fooProm.thenThrow(err);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.catchReturn(bar);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
// fooProm
|
||||
fooProm = fooProm.catchThrow(err);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
str = fooProm.toString();
|
||||
|
||||
obj = fooProm.toJSON();
|
||||
|
||||
Vendored
+31
@@ -248,6 +248,37 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
|
||||
throw(reason: Error): Bluebird<R>;
|
||||
thenThrow(reason: Error): Bluebird<R>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .catch(function() {
|
||||
* return value;
|
||||
* });
|
||||
* </code>
|
||||
*
|
||||
* in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.catchReturn()`
|
||||
*/
|
||||
catchReturn<U>(value: U): Bluebird<U>;
|
||||
catchReturn<U>(predicate: (error: any) => boolean, value: U): Bluebird<U | R>;
|
||||
catchReturn<E extends Error, U>(ErrorClass: new (...args: any[]) => E, value: U): Bluebird<U | R>;
|
||||
catchReturn<U>(predicate: Object, value: U): Bluebird<U | R>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .catch(function() {
|
||||
* throw reason;
|
||||
* });
|
||||
* </code>
|
||||
* Same limitations apply as with `.catchReturn()`.
|
||||
*/
|
||||
catchThrow(reason: Error): Bluebird<R>;
|
||||
catchThrow(predicate: (error: any) => boolean, reason: Error): Bluebird<R>;
|
||||
catchThrow<E extends Error, U>(ErrorClass: new (...args: any[]) => E, reason: Error): Bluebird<R>;
|
||||
catchThrow(predicate: Object, reason: Error): Bluebird<R>;
|
||||
|
||||
/**
|
||||
* Convert to String.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user