refactor(benchpress): make tests for error cases also work in Dart
Also introduces `PromiseWrapper.catchError`. Could not use `PromiseWrapper.catch` as a name as Dart would not allow this method name.
This commit is contained in:
@ -15,6 +15,12 @@ class PromiseWrapper {
|
||||
return promise.then(success, onError: onError);
|
||||
}
|
||||
|
||||
// Note: We can't rename this method to `catch`, as this is not a valid
|
||||
// method name in Dart.
|
||||
static Future catchError(Future promise, Function onError) {
|
||||
return promise.catchError(onError);
|
||||
}
|
||||
|
||||
static _Completer completer() => new _Completer(new Completer());
|
||||
|
||||
static void setTimeout(fn(), int millis) {
|
||||
|
@ -12,6 +12,12 @@ export class PromiseWrapper {
|
||||
return Promise.reject(obj);
|
||||
}
|
||||
|
||||
// Note: We can't rename this method into `catch`, as this is not a valid
|
||||
// method name in Dart.
|
||||
static catchError(promise:Promise, onError:Function):Promise {
|
||||
return promise.catch(onError);
|
||||
}
|
||||
|
||||
static all(promises:List):Promise {
|
||||
if (promises.length == 0) return Promise.resolve([]);
|
||||
return Promise.all(promises);
|
||||
|
Reference in New Issue
Block a user