-
Notifications
You must be signed in to change notification settings - Fork 204
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
Crash iOS app when throwing error on kotlin flow #818
Conversation
Detekt check failed. Please run |
2486ce4
to
7e9a7c5
Compare
Detekt check failed. Please run |
7e9a7c5
to
ba6ace7
Compare
ba6ace7
to
f2a7e76
Compare
It seems this is the issue: touchlab/SKIE#19. |
@@ -36,6 +38,10 @@ public class DefaultContributorsRepository( | |||
refresh() | |||
} | |||
} | |||
.catch { | |||
Logger.e("Fail getContributorStream: $it") |
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.
I think we can pass throwable to Logger.e parameter 👀
@@ -36,6 +38,10 @@ public class DefaultContributorsRepository( | |||
refresh() | |||
} | |||
} | |||
.catch { |
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.
How about adding a comment for each .catch
block?
// SKIE doesn't support throwing exceptions from Flow.
// For more information, please refer to https://github.com/touchlab/SKIE/discussions/19 .
if (first) { | ||
first = false | ||
Logger.d("DefaultSessionsRepository onStart getTimetableStream()") | ||
sessionCacheDataStore.save(sessionsApi.sessionsAllResponse()) |
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.
The sessionsApi.sessionsAllResponse
is likely to throw an error.
try {
sessionCacheDataStore.save(sessionsApi.sessionsAllResponse())
} catch (e: Exception) {
// SKIE doesn't support throwing exceptions from Flow.
// For more information, please refer to https://github.com/touchlab/SKIE/discussions/19 .
coroutineContext.ensureActive()
Logger.e(e, "Fail to refresh Timetable in getTimetableStream()")
}
@takahirom |
@takahirom |
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.
Looks good!
Issue
Overview (Required)
When error is thrown on kotlin flow, iOS app crash.
According to this article, Skie does not propagate errors that occur in Flow to the iOS side.
https://touchlab.co/skie-migration?ti=44D6E96AB6894C3C883219A3B4#flow-support
Therefore, I added error catch logic to kotlin flow.
In fact, I would like to pass the Result type to iOS for error handling on the iOS side, but since the type would be AnyObject, our priority at this stage is to avoid crashes.
Links
Screenshot (Optional if screenshot test is present or unrelated to UI)
Movie (Optional)