-
Notifications
You must be signed in to change notification settings - Fork 12
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
Better coroutine error handling #54
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion this solution is good, but didn't cover all cases. For example, in case of http issues we will receive exception on this line and this exception will be handled by existing CoroutineWrapper class.
So, my suggestion is maybe it will be better to improve CoroutineWrapper class that we can set up errorHandler action on it, and execute it instead of current Completed?.Invoke(default);
And when we wrap with it all coroutines that runs external callbacks and returns through yield return coroutine
statement, looks like we will cover all possible exception cases.
Moreover looks like that WrappedRequest method is redundant, we can use ordinary CoroutineWrapper
instead.
If you have any thoughts, feel free to write me.
I really forgot about the CoroutineWrapper and WrappedRequest usages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution did not cover scenarios which are build on several yield return IEnumerator
cases. E.g. if we click on Inventory button on UI, we will call this method, that will call GetJson<T>
method later, and if we have some network issues, we will get deserealize exception on this line, even if we pass errorHandler on CoroutineUtils.TryWith
So, my previous suggestion was to use something like CoroutineWrappper, that can handle Exceptions inside itself and use them wherever possible.
@fraidev what do you think? |
Make sense! I reverted the last commits and added one using the |
@fraidev could you please update the changelog? |
This PR resolves #39
I added class CoroutineUtils.cs that has two methods: