Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

delay() should throw a custom exception, implement throwIfCanceled() #93

Open
@appkit-framework

Description

Hello,

I believe it would be more appropriate for delay() to throw a custom exception specific to cancellation (e.g., CanceledException) instead of a standard PHP's \RuntimeException.
This would allow developers to more easily distinguish between expected cancellations and other unexpected errors.

Additionally, it would be great if ReactPHP could provide a helper function, like this one:

function throwIfCanceled() {
 await(new Promise(
 function($resolve) {
 $resolve(null);
 },
 function() {
 throw new CanceledException();
 }
 ));
}

This would allow developers to handle the cancellation of asynchronous tasks at specific points in the code, such as after each iteration of a long-running loop (essentially the same as delay(0)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /