Uh oh!
There was an error while loading. Please reload this page.
Enforce throwables/exceptions as rejection reasons - #93
Conversation
66ce56b to
411a415Compare| namespace React\Promise\Exception; | ||
| class CompositeException extends \Exception |
There was a problem hiding this comment.
No objections to either class name, but the use of this class appears a bit unclear. Does it make sense to add documentation for this class and/or mark this class a @internal?
There was a problem hiding this comment.
Added documentation in 07b7afd. I think it makes sense to keep it public API as it might be useful for custom collection functions.
clue
commented
Mar 16, 2017
I like the idea of only accepting |
jsor
commented
Mar 16, 2017
@clue I thought about that myself, but if only ini_set('assert.exception', 1);
$promise = new \React\Promise\Promise(function() {
assert(1 === 0);
});
$nextPromise = $promise->otherwise(function($e) {
handle($e);
// $e is AssertionError and can't be passed to reject()return\React\Promise\reject($e);
});A solution would be to just rethrow, but that needs to be documented (and the documentation read by the user). $nextPromise = $promise->otherwise(function($e) {
handle($e);
throw$e;
}); |
kelunik
commented
Mar 16, 2017
@clue Why would one want to not support |
WyriHaximus
commented
Mar 16, 2017
Explicitly not supporting |
stefanotorresi
commented
Mar 21, 2017
isn't the point of this PR to be "not longer possible to reject a promise without a reason |
I'm 👍 on getting this in and didn't mean to question whether supporting |
jsor
commented
Apr 5, 2017
@clue In fact, |
jsor
commented
Aug 24, 2017
Ping @clue |
clue
left a comment
There was a problem hiding this comment.
Good catch! I think this feature and corresponding BC break makes perfect sense 👍
I have a couple of questions regarding the new custom exception classes, otherwise LGTM 👍
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| namespace React\Promise\Exception; | ||
| class CompositeException extends \Exception |
There was a problem hiding this comment.
No objections to either class name, but the use of this class appears a bit unclear. Does it make sense to add documentation for this class and/or mark this class a @internal?
Uh oh!
There was an error while loading. Please reload this page.
a2809c2 to
df0976eComparekelunik
commented
Feb 21, 2018
@jsor Would you be up for standardizing the |
I've added [WIP] to the PR title. We still need to figure out how we can keep interoperabilty with other promise implementations which allow rejecting with non-exception reasons. newPromise(function($resolve, $reject) use ($foreignPromise) {
$foreignPromise->then($resolve, $reject);
});This would now reject One solution would be to wrap the reason in a |
clue
commented
Jun 12, 2018
Do we have a relevant use case where this happens? |
jsor
commented
Jun 12, 2018
clue
commented
Jun 20, 2018
@jsor It's my understanding that if a foreign promise rejects with something that is not an As far as I can tell, the ecosystem of foreign promises also seem to rely on Are you seeing anything that is missing here and/or is commonly used in other projects? |
jsor
commented
Apr 18, 2019
ping @clue |
clue
commented
Apr 18, 2019
One thing: Once this is in, I would like to look into enforcing a |
WyriHaximus
commented
Apr 18, 2019
Well either of us can do that, but I'd like to get an PR out A.S.A.P. adding exactly that and raising minimum PHP version to 7.0 |
clue
commented
Apr 19, 2019
@WyriHaximus Go for it! |
WyriHaximus
commented
Apr 19, 2019
@clue 🎉 ! |
Because rejections are the promise counter parts of throwing an exception, throwables/exceptions should be enforced as rejection reasons.
Also, ReactPHP has always used exceptions as rejection reasons throughout it's components.
Closes#46