From b42dc4623f2b5bfdb7554b054e6e8a638e41b417 Mon Sep 17 00:00:00 2001 From: y9vad9 Date: Wed, 26 Jul 2023 18:38:16 +0200 Subject: [PATCH] fix: `Status.RESOURCE_EXHAUSTED` wasn't handled --- .../io/timemates/api/grpc/GrpcTimeMatesRequestsEngine.kt | 4 ++++ .../sdk/common/exceptions/TooManyRequestsException.kt | 1 + 2 files changed, 5 insertions(+) diff --git a/grpc-engine/src/main/kotlin/io/timemates/api/grpc/GrpcTimeMatesRequestsEngine.kt b/grpc-engine/src/main/kotlin/io/timemates/api/grpc/GrpcTimeMatesRequestsEngine.kt index 9f8d230..c1e58e3 100644 --- a/grpc-engine/src/main/kotlin/io/timemates/api/grpc/GrpcTimeMatesRequestsEngine.kt +++ b/grpc-engine/src/main/kotlin/io/timemates/api/grpc/GrpcTimeMatesRequestsEngine.kt @@ -33,6 +33,7 @@ import io.timemates.sdk.common.exceptions.InternalServerError import io.timemates.sdk.common.exceptions.InvalidArgumentException import io.timemates.sdk.common.exceptions.NotFoundException import io.timemates.sdk.common.exceptions.PermissionDeniedException +import io.timemates.sdk.common.exceptions.TooManyRequestsException import io.timemates.sdk.common.exceptions.UnauthorizedException import io.timemates.sdk.common.exceptions.UnavailableException import io.timemates.sdk.common.exceptions.UnsupportedException @@ -383,6 +384,9 @@ public class GrpcTimeMatesRequestsEngine( val message = exception.message ?: NO_MESSAGE when (status) { + Status.RESOURCE_EXHAUSTED -> + TooManyRequestsException("Too many requests.", exception) + Status.INVALID_ARGUMENT, Status.FAILED_PRECONDITION -> InvalidArgumentException(message, exception) diff --git a/sdk/src/commonMain/kotlin/io/timemates/sdk/common/exceptions/TooManyRequestsException.kt b/sdk/src/commonMain/kotlin/io/timemates/sdk/common/exceptions/TooManyRequestsException.kt index b9bd897..730c4c1 100644 --- a/sdk/src/commonMain/kotlin/io/timemates/sdk/common/exceptions/TooManyRequestsException.kt +++ b/sdk/src/commonMain/kotlin/io/timemates/sdk/common/exceptions/TooManyRequestsException.kt @@ -9,4 +9,5 @@ package io.timemates.sdk.common.exceptions */ public data class TooManyRequestsException( override val message: String, + override val cause: Throwable?, ) : TimeMatesException(message) \ No newline at end of file