Skip to content

Commit

Permalink
Handle status exception for updateDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Jul 1, 2024
1 parent b9ef0f5 commit d76dfbd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import net.mullvad.mullvadvpn.lib.model.DeleteDeviceError
import net.mullvad.mullvadvpn.lib.model.Device
import net.mullvad.mullvadvpn.lib.model.DeviceId
import net.mullvad.mullvadvpn.lib.model.DeviceState as ModelDeviceState
import net.mullvad.mullvadvpn.lib.model.DeviceUpdateError
import net.mullvad.mullvadvpn.lib.model.DnsOptions as ModelDnsOptions
import net.mullvad.mullvadvpn.lib.model.DnsOptions
import net.mullvad.mullvadvpn.lib.model.DnsState as ModelDnsState
Expand Down Expand Up @@ -233,9 +234,10 @@ class ManagementService(
.map { it.toDomain() }
.mapLeft { GetDeviceStateError.Unknown(it) }

suspend fun updateDevice() {
grpc.updateDevice(Empty.getDefaultInstance())
}
suspend fun updateDevice(): Either<DeviceUpdateError, Unit> =
Either.catch { grpc.updateDevice(Empty.getDefaultInstance()) }
.mapEmpty()
.mapLeft { DeviceUpdateError(it) }

suspend fun getDeviceList(token: AccountNumber): Either<GetDeviceListError, List<Device>> =
Either.catch { grpc.listDevices(StringValue.of(token.value)) }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package net.mullvad.mullvadvpn.lib.model

data class DeviceUpdateError(val error: Throwable)

0 comments on commit d76dfbd

Please sign in to comment.