Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.96.0"
".": "0.96.1"
}
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.96.1 (2025-07-18)

Full Changelog: [v0.96.0...v0.96.1](https://github.com/lithic-com/lithic-java/compare/v0.96.0...v0.96.1)

### Bug Fixes

* **client:** ensure error handling always occurs ([037c1ff](https://github.com/lithic-com/lithic-java/commit/037c1ffd0e92cb6e86f9e434f96f9cff6a6393e2))


### Chores

* fix conflict ([83182ce](https://github.com/lithic-com/lithic-java/commit/83182ce0bcaf7edb9d5874e2496c3ea6314295a9))
* **internal:** allow running specific example from cli ([59ee949](https://github.com/lithic-com/lithic-java/commit/59ee949248a1e53456df67804bbae9ccb2a258d3))

## 0.96.0 (2025-07-15)

Full Changelog: [v0.95.0...v0.96.0](https://github.com/lithic-com/lithic-java/compare/v0.95.0...v0.96.0)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.96.0)
[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.96.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.96.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.96.1)
[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.96.1/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.96.1)

<!-- x-release-please-end -->

Expand All @@ -13,7 +13,7 @@ The Lithic Java SDK is similar to the Lithic Kotlin SDK but with minor differenc

<!-- x-release-please-start-version -->

The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.96.0).
The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.96.1).

<!-- x-release-please-end -->

Expand All @@ -24,7 +24,7 @@ The REST API documentation can be found on [docs.lithic.com](https://docs.lithic
### Gradle

```kotlin
implementation("com.lithic.api:lithic-java:0.96.0")
implementation("com.lithic.api:lithic-java:0.96.1")
```

### Maven
Expand All @@ -33,7 +33,7 @@ implementation("com.lithic.api:lithic-java:0.96.0")
<dependency>
<groupId>com.lithic.api</groupId>
<artifactId>lithic-java</artifactId>
<version>0.96.0</version>
<version>0.96.1</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repositories {

allprojects {
group = "com.lithic.api"
version = "0.96.0" // x-release-please-version
version = "0.96.1" // x-release-please-version
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
package com.lithic.api.client

import com.lithic.api.core.ClientOptions
import com.lithic.api.core.JsonValue
import com.lithic.api.core.RequestOptions
import com.lithic.api.core.getPackageVersion
import com.lithic.api.core.handlers.errorBodyHandler
import com.lithic.api.core.handlers.errorHandler
import com.lithic.api.core.handlers.jsonHandler
import com.lithic.api.core.handlers.withErrorHandler
import com.lithic.api.core.http.HttpMethod
import com.lithic.api.core.http.HttpRequest
import com.lithic.api.core.http.HttpResponse
import com.lithic.api.core.http.HttpResponse.Handler
import com.lithic.api.core.http.HttpResponseFor
import com.lithic.api.core.http.parseable
Expand Down Expand Up @@ -285,7 +285,8 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl
class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
LithicClientAsync.WithRawResponse {

private val errorHandler: Handler<JsonValue> = errorHandler(clientOptions.jsonMapper)
private val errorHandler: Handler<HttpResponse> =
errorHandler(errorBodyHandler(clientOptions.jsonMapper))

private val accounts: AccountServiceAsync.WithRawResponse by lazy {
AccountServiceAsyncImpl.WithRawResponseImpl(clientOptions)
Expand Down Expand Up @@ -472,7 +473,7 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl
override fun networkPrograms(): NetworkProgramServiceAsync.WithRawResponse = networkPrograms

private val apiStatusHandler: Handler<ApiStatus> =
jsonHandler<ApiStatus>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
jsonHandler<ApiStatus>(clientOptions.jsonMapper)

override fun apiStatus(
params: ClientApiStatusParams,
Expand All @@ -489,7 +490,7 @@ class LithicClientAsyncImpl(private val clientOptions: ClientOptions) : LithicCl
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { apiStatusHandler.handle(it) }
.also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
package com.lithic.api.client

import com.lithic.api.core.ClientOptions
import com.lithic.api.core.JsonValue
import com.lithic.api.core.RequestOptions
import com.lithic.api.core.getPackageVersion
import com.lithic.api.core.handlers.errorBodyHandler
import com.lithic.api.core.handlers.errorHandler
import com.lithic.api.core.handlers.jsonHandler
import com.lithic.api.core.handlers.withErrorHandler
import com.lithic.api.core.http.HttpMethod
import com.lithic.api.core.http.HttpRequest
import com.lithic.api.core.http.HttpResponse
import com.lithic.api.core.http.HttpResponse.Handler
import com.lithic.api.core.http.HttpResponseFor
import com.lithic.api.core.http.parseable
Expand Down Expand Up @@ -267,7 +267,8 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient
class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
LithicClient.WithRawResponse {

private val errorHandler: Handler<JsonValue> = errorHandler(clientOptions.jsonMapper)
private val errorHandler: Handler<HttpResponse> =
errorHandler(errorBodyHandler(clientOptions.jsonMapper))

private val accounts: AccountService.WithRawResponse by lazy {
AccountServiceImpl.WithRawResponseImpl(clientOptions)
Expand Down Expand Up @@ -453,7 +454,7 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient
override fun networkPrograms(): NetworkProgramService.WithRawResponse = networkPrograms

private val apiStatusHandler: Handler<ApiStatus> =
jsonHandler<ApiStatus>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
jsonHandler<ApiStatus>(clientOptions.jsonMapper)

override fun apiStatus(
params: ClientApiStatusParams,
Expand All @@ -468,7 +469,7 @@ class LithicClientImpl(private val clientOptions: ClientOptions) : LithicClient
.prepare(clientOptions, params)
val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions))
val response = clientOptions.httpClient.execute(request, requestOptions)
return response.parseable {
return errorHandler.handle(response).parseable {
response
.use { apiStatusHandler.handle(it) }
.also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.lithic.api.errors.UnexpectedStatusCodeException
import com.lithic.api.errors.UnprocessableEntityException

@JvmSynthetic
internal fun errorHandler(jsonMapper: JsonMapper): Handler<JsonValue> {
internal fun errorBodyHandler(jsonMapper: JsonMapper): Handler<JsonValue> {
val handler = jsonHandler<JsonValue>(jsonMapper)

return object : Handler<JsonValue> {
Expand All @@ -33,52 +33,52 @@ internal fun errorHandler(jsonMapper: JsonMapper): Handler<JsonValue> {
}

@JvmSynthetic
internal fun <T> Handler<T>.withErrorHandler(errorHandler: Handler<JsonValue>): Handler<T> =
object : Handler<T> {
override fun handle(response: HttpResponse): T =
internal fun errorHandler(errorBodyHandler: Handler<JsonValue>): Handler<HttpResponse> =
object : Handler<HttpResponse> {
override fun handle(response: HttpResponse): HttpResponse =
when (val statusCode = response.statusCode()) {
in 200..299 -> this@withErrorHandler.handle(response)
in 200..299 -> response
400 ->
throw BadRequestException.builder()
.headers(response.headers())
.body(errorHandler.handle(response))
.body(errorBodyHandler.handle(response))
.build()
401 ->
throw UnauthorizedException.builder()
.headers(response.headers())
.body(errorHandler.handle(response))
.body(errorBodyHandler.handle(response))
.build()
403 ->
throw PermissionDeniedException.builder()
.headers(response.headers())
.body(errorHandler.handle(response))
.body(errorBodyHandler.handle(response))
.build()
404 ->
throw NotFoundException.builder()
.headers(response.headers())
.body(errorHandler.handle(response))
.body(errorBodyHandler.handle(response))
.build()
422 ->
throw UnprocessableEntityException.builder()
.headers(response.headers())
.body(errorHandler.handle(response))
.body(errorBodyHandler.handle(response))
.build()
429 ->
throw RateLimitException.builder()
.headers(response.headers())
.body(errorHandler.handle(response))
.body(errorBodyHandler.handle(response))
.build()
in 500..599 ->
throw InternalServerException.builder()
.statusCode(statusCode)
.headers(response.headers())
.body(errorHandler.handle(response))
.body(errorBodyHandler.handle(response))
.build()
else ->
throw UnexpectedStatusCodeException.builder()
.statusCode(statusCode)
.headers(response.headers())
.body(errorHandler.handle(response))
.body(errorBodyHandler.handle(response))
.build()
}
}
Loading