Skip to content

Commit 8cfda8e

Browse files
committed
fix(internal): fix error handlers on ClientImpl
1 parent c85d73a commit 8cfda8e

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ package com.tryfinch.api.client
44

55
import com.fasterxml.jackson.annotation.JsonProperty
66
import com.tryfinch.api.core.ClientOptions
7-
import com.tryfinch.api.core.JsonValue
87
import com.tryfinch.api.core.getPackageVersion
8+
import com.tryfinch.api.core.handlers.errorBodyHandler
99
import com.tryfinch.api.core.handlers.errorHandler
1010
import com.tryfinch.api.core.handlers.jsonHandler
11-
import com.tryfinch.api.core.handlers.withErrorHandler
1211
import com.tryfinch.api.core.http.HttpMethod
1312
import com.tryfinch.api.core.http.HttpRequest
13+
import com.tryfinch.api.core.http.HttpResponse
1414
import com.tryfinch.api.core.http.HttpResponse.Handler
1515
import com.tryfinch.api.core.http.json
1616
import com.tryfinch.api.errors.FinchException
@@ -41,7 +41,8 @@ import java.util.function.Consumer
4141

4242
class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClientAsync {
4343

44-
private val errorHandler: Handler<JsonValue> = errorHandler(clientOptions.jsonMapper)
44+
private val errorHandler: Handler<HttpResponse> =
45+
errorHandler(errorBodyHandler(clientOptions.jsonMapper))
4546

4647
private val clientOptionsWithUserAgent =
4748
if (clientOptions.headers.names().contains("User-Agent")) clientOptions
@@ -94,7 +95,7 @@ class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClie
9495
}
9596

9697
private val getAccessTokenHandler: Handler<GetAccessTokenResponse> =
97-
jsonHandler<GetAccessTokenResponse>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
98+
jsonHandler<GetAccessTokenResponse>(clientOptions.jsonMapper)
9899

99100
override fun sync(): FinchClient = sync
100101

finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ package com.tryfinch.api.client
44

55
import com.fasterxml.jackson.annotation.JsonProperty
66
import com.tryfinch.api.core.ClientOptions
7-
import com.tryfinch.api.core.JsonValue
87
import com.tryfinch.api.core.getPackageVersion
8+
import com.tryfinch.api.core.handlers.errorBodyHandler
99
import com.tryfinch.api.core.handlers.errorHandler
1010
import com.tryfinch.api.core.handlers.jsonHandler
11-
import com.tryfinch.api.core.handlers.withErrorHandler
1211
import com.tryfinch.api.core.http.HttpMethod
1312
import com.tryfinch.api.core.http.HttpRequest
13+
import com.tryfinch.api.core.http.HttpResponse
1414
import com.tryfinch.api.core.http.HttpResponse.Handler
1515
import com.tryfinch.api.core.http.json
1616
import com.tryfinch.api.errors.FinchException
@@ -40,7 +40,8 @@ import java.util.function.Consumer
4040

4141
class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient {
4242

43-
private val errorHandler: Handler<JsonValue> = errorHandler(clientOptions.jsonMapper)
43+
private val errorHandler: Handler<HttpResponse> =
44+
errorHandler(errorBodyHandler(clientOptions.jsonMapper))
4445

4546
private val clientOptionsWithUserAgent =
4647
if (clientOptions.headers.names().contains("User-Agent")) clientOptions
@@ -83,7 +84,7 @@ class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient {
8384
private val connect: ConnectService by lazy { ConnectServiceImpl(clientOptionsWithUserAgent) }
8485

8586
private val getAccessTokenHandler: Handler<GetAccessTokenResponse> =
86-
jsonHandler<GetAccessTokenResponse>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
87+
jsonHandler<GetAccessTokenResponse>(clientOptions.jsonMapper)
8788

8889
override fun async(): FinchClientAsync = async
8990

0 commit comments

Comments
 (0)