Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add cancellation tokens #285

Merged
merged 3 commits into from
Jun 5, 2024
Merged

Conversation

rk132
Copy link
Contributor

@rk132 rk132 commented Jun 3, 2024

SDK-971

Description

  • Update methods to throw an error, when cancellationToken was called, and handle them in the Elements scene

@rk132 rk132 requested a review from a team as a code owner June 3, 2024 12:47
@@ -76,6 +76,7 @@ public async Task<AvatarCreationResponse> CreateAvatarAsync(AvatarProperties ava
}
catch (Exception e)
{
ThrowErrIfCancellationException(e);
Copy link
Collaborator

@HarrisonHough HarrisonHough Jun 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's super annoying that we have to add this in all the exception parts of this script.
It could be moved into some sort of "HandleException(ex)" function to reduce the code duplication.
Eg

        private void HandleException(Exception e)
        {

            ThrowErrIfCancellationException(e);
            OnError?.Invoke(e.Message);
        }

It might also be nice in future to change the OnError action to have a parameter of type Exception. Then we can just use that for everthing (including throwing the cancellation exception). It would be a breaking change though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, can move onError there as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can actually use the built in exclude logic to handle this, if you wanted a more graceful solution ->

catch (Exception ex) when (ex is not OperationCanceledException)

https://stackoverflow.com/questions/12633903/elegantly-handle-task-cancellation

Copy link
Collaborator

@HarrisonHough HarrisonHough left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cancellation token stuff is okay but I don't think we should be throwing errors like this.
people are going to freak out when they see all these errors even though it's not a breaking error
image
maybe warnings or something but even then it's gonna spam the logs, happy to discuss though

@HarrisonHough HarrisonHough self-requested a review June 5, 2024 09:33
Copy link
Collaborator

@HarrisonHough HarrisonHough left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this btw

@rk132 rk132 merged commit 0c75bd6 into develop Jun 5, 2024
@rk132 rk132 deleted the feature/add-cancellation-tokens branch June 5, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants