fix: Distinguish between an empty response and a network error (#1938)

This commit is contained in:
James Rich 2025-05-25 20:41:49 -05:00 committed by GitHub
parent be437ebb91
commit 139a17f22f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 13 additions and 8 deletions

View file

@ -52,7 +52,9 @@ class DeviceHardwareRepository @Inject constructor(
}
try {
debug("Fetching device hardware from server")
localDataSource.insertAllDeviceHardware(apiDataSource.getAllDeviceHardware())
val deviceHardware = apiDataSource.getAllDeviceHardware()
?: throw IOException("empty response from server")
localDataSource.insertAllDeviceHardware(deviceHardware)
val cachedHardware = localDataSource.getByHwModel(hwModel)
val externalModel = cachedHardware?.asExternalModel()
return@withContext externalModel

View file

@ -61,6 +61,7 @@ class FirmwareReleaseRepository @Inject constructor(
try {
debug("Fetching firmware releases from server")
val networkFirmwareReleases = apiDataSource.getFirmwareReleases()
?: throw IOException("empty response from server")
val releases = when (releaseType) {
FirmwareReleaseType.STABLE -> networkFirmwareReleases.releases.stable
FirmwareReleaseType.ALPHA -> networkFirmwareReleases.releases.alpha