-
Notifications
You must be signed in to change notification settings - Fork 306
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
Fix sync state exception handling #1669
Changes from 4 commits
52ceb2d
71ca622
65f8e44
5a6f8b7
0913137
fcc0dbd
116df94
5f8c07d
cfd11ae
3f25e49
cee67c2
5e6a522
f10d8e8
59852af
a0326af
c60eeba
adcba26
b84237e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright 2021 Google LLC | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -21,10 +21,10 @@ import com.google.android.fhir.sync.DataSource | |
import com.google.android.fhir.sync.DownloadState | ||
import com.google.android.fhir.sync.DownloadWorkManager | ||
import com.google.android.fhir.sync.Downloader | ||
import com.google.android.fhir.sync.ResourceSyncException | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import org.hl7.fhir.r4.model.ResourceType | ||
import timber.log.Timber | ||
|
||
/** | ||
* Implementation of the [Downloader]. It orchestrates the pre & post processing of resources via | ||
|
@@ -53,7 +53,7 @@ internal class DownloaderImpl( | |
) | ||
) | ||
} catch (exception: Exception) { | ||
emit(DownloadState.Failure(ResourceSyncException(resourceTypeToDownload, exception))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we may not want to remove this line. sync should emit failure when resource syncing fails. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. I have reverted this line so this state can be emitted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But this needs to be handled not only by the implementers but also in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. emitting events in catch block is however not recommended because of such unexpected behaviors when the exception is not correctly handle where we are collecting the states for the flow. |
||
Timber.e(exception, "Resource type $resourceTypeToDownload failed to sync") | ||
} | ||
|
||
url = downloadWorkManager.getNextRequestUrl(context) | ||
|
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.
we may not want to just catch exception for resources which have failed to save. it should either show this error to user, or it should do something to log error somewhere to resolve the issue with DB. this can lead to suppress app issues with data collection without getting noticed.
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 agree we may need to do more with this error log but do we really want to show the user this error? Is there a strategy in SDK for handling/logging errors?