Skip to content

Commit

Permalink
feat(future): avoid unhandled rejections
Browse files Browse the repository at this point in the history
Futures are intended to wrap promises, and therefore should not leak
details about unhandled rejections.  This commit changes some logic to
align with that goal.
  • Loading branch information
jklmli committed Mar 17, 2018
1 parent 7c0814c commit f57281e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/future/future.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Future<A> {
.catch((error: Error): Promise<A> => {
this.value_ = Option(Try(() => { throw error; }));

throw error;
return promise;
});
}

Expand All @@ -65,10 +65,8 @@ class Future<A> {
reject(new Error('Future.filter predicate is not satisfied'));
}
})
.catch((error: Error): Promise<A> => {
.catch((error: Error): void => {
reject(error);

throw error;
});
})
);
Expand All @@ -89,10 +87,8 @@ class Future<A> {
reject(error as Error);
}
})
.catch((error: Error): Promise<A> => {
.catch((error: Error): void => {
reject(error);

throw error;
});
})
);
Expand All @@ -102,6 +98,9 @@ class Future<A> {
this.promise
.then((value: A): void => {
run(value);
})
.catch((error: Error): void => {
// Don't do anything on failure.
});
}

Expand Down

0 comments on commit f57281e

Please sign in to comment.