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 @@
{
".": "1.5.0"
".": "1.5.1"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 116
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-612316c13276a207f56e2e2c7bbc68f4bb73de85e3661595a23f23d9ccc80276.yml
openapi_spec_hash: 6e125f05e40521ec485edf6e15beec2e
config_hash: 3c3524be9607afb24d2139ce26ce5389
config_hash: 8c9a47f104c777e2a1e8f3fad15c093b
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.5.1 (2025-07-17)

Full Changelog: [v1.5.0...v1.5.1](https://github.com/orbcorp/orb-java/compare/v1.5.0...v1.5.1)

### Bug Fixes

* **client:** ensure error handling always occurs ([833326e](https://github.com/orbcorp/orb-java/commit/833326e6f35b4b8575002fc31f89f8292343a9e0))

## 1.5.0 (2025-07-16)

Full Changelog: [v1.4.0...v1.5.0](https://github.com/orbcorp/orb-java/compare/v1.4.0...v1.5.0)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.5.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/1.5.1)

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

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

```kotlin
implementation("com.withorb.api:orb-java:1.5.0")
implementation("com.withorb.api:orb-java:1.5.1")
```

### Maven
Expand All @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:1.5.0")
<dependency>
<groupId>com.withorb.api</groupId>
<artifactId>orb-java</artifactId>
<version>1.5.0</version>
<version>1.5.1</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
allprojects {
group = "com.withorb.api"
version = "1.5.0" // x-release-please-version
version = "1.5.1" // x-release-please-version
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.withorb.api.errors.UnexpectedStatusCodeException
import com.withorb.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 -> [email protected](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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
package com.withorb.api.services.async

import com.withorb.api.core.ClientOptions
import com.withorb.api.core.JsonValue
import com.withorb.api.core.RequestOptions
import com.withorb.api.core.checkRequired
import com.withorb.api.core.handlers.errorBodyHandler
import com.withorb.api.core.handlers.errorHandler
import com.withorb.api.core.handlers.jsonHandler
import com.withorb.api.core.handlers.withErrorHandler
import com.withorb.api.core.http.HttpMethod
import com.withorb.api.core.http.HttpRequest
import com.withorb.api.core.http.HttpResponse
import com.withorb.api.core.http.HttpResponse.Handler
import com.withorb.api.core.http.HttpResponseFor
import com.withorb.api.core.http.json
Expand Down Expand Up @@ -102,7 +102,8 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
AlertServiceAsync.WithRawResponse {

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

override fun withOptions(
modifier: Consumer<ClientOptions.Builder>
Expand All @@ -111,8 +112,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
clientOptions.toBuilder().apply(modifier::accept).build()
)

private val retrieveHandler: Handler<Alert> =
jsonHandler<Alert>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
private val retrieveHandler: Handler<Alert> = jsonHandler<Alert>(clientOptions.jsonMapper)

override fun retrieve(
params: AlertRetrieveParams,
Expand All @@ -132,7 +132,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { retrieveHandler.handle(it) }
.also {
Expand All @@ -144,8 +144,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
}
}

private val updateHandler: Handler<Alert> =
jsonHandler<Alert>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
private val updateHandler: Handler<Alert> = jsonHandler<Alert>(clientOptions.jsonMapper)

override fun update(
params: AlertUpdateParams,
Expand All @@ -166,7 +165,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { updateHandler.handle(it) }
.also {
Expand All @@ -180,7 +179,6 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie

private val listHandler: Handler<AlertListPageResponse> =
jsonHandler<AlertListPageResponse>(clientOptions.jsonMapper)
.withErrorHandler(errorHandler)

override fun list(
params: AlertListParams,
Expand All @@ -197,7 +195,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { listHandler.handle(it) }
.also {
Expand All @@ -218,7 +216,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
}

private val createForCustomerHandler: Handler<Alert> =
jsonHandler<Alert>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
jsonHandler<Alert>(clientOptions.jsonMapper)

override fun createForCustomer(
params: AlertCreateForCustomerParams,
Expand All @@ -239,7 +237,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { createForCustomerHandler.handle(it) }
.also {
Expand All @@ -252,7 +250,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
}

private val createForExternalCustomerHandler: Handler<Alert> =
jsonHandler<Alert>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
jsonHandler<Alert>(clientOptions.jsonMapper)

override fun createForExternalCustomer(
params: AlertCreateForExternalCustomerParams,
Expand All @@ -273,7 +271,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { createForExternalCustomerHandler.handle(it) }
.also {
Expand All @@ -286,7 +284,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
}

private val createForSubscriptionHandler: Handler<Alert> =
jsonHandler<Alert>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
jsonHandler<Alert>(clientOptions.jsonMapper)

override fun createForSubscription(
params: AlertCreateForSubscriptionParams,
Expand All @@ -307,7 +305,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { createForSubscriptionHandler.handle(it) }
.also {
Expand All @@ -319,8 +317,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
}
}

private val disableHandler: Handler<Alert> =
jsonHandler<Alert>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
private val disableHandler: Handler<Alert> = jsonHandler<Alert>(clientOptions.jsonMapper)

override fun disable(
params: AlertDisableParams,
Expand All @@ -341,7 +338,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { disableHandler.handle(it) }
.also {
Expand All @@ -353,8 +350,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
}
}

private val enableHandler: Handler<Alert> =
jsonHandler<Alert>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
private val enableHandler: Handler<Alert> = jsonHandler<Alert>(clientOptions.jsonMapper)

override fun enable(
params: AlertEnableParams,
Expand All @@ -375,7 +371,7 @@ class AlertServiceAsyncImpl internal constructor(private val clientOptions: Clie
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { enableHandler.handle(it) }
.also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
package com.withorb.api.services.async

import com.withorb.api.core.ClientOptions
import com.withorb.api.core.JsonValue
import com.withorb.api.core.RequestOptions
import com.withorb.api.core.checkRequired
import com.withorb.api.core.handlers.errorBodyHandler
import com.withorb.api.core.handlers.errorHandler
import com.withorb.api.core.handlers.jsonHandler
import com.withorb.api.core.handlers.withErrorHandler
import com.withorb.api.core.http.HttpMethod
import com.withorb.api.core.http.HttpRequest
import com.withorb.api.core.http.HttpResponse
import com.withorb.api.core.http.HttpResponse.Handler
import com.withorb.api.core.http.HttpResponseFor
import com.withorb.api.core.http.json
Expand Down Expand Up @@ -69,7 +69,8 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien
class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) :
BetaServiceAsync.WithRawResponse {

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

private val externalPlanId: ExternalPlanIdServiceAsync.WithRawResponse by lazy {
ExternalPlanIdServiceAsyncImpl.WithRawResponseImpl(clientOptions)
Expand All @@ -85,7 +86,7 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien
override fun externalPlanId(): ExternalPlanIdServiceAsync.WithRawResponse = externalPlanId

private val createPlanVersionHandler: Handler<PlanVersion> =
jsonHandler<PlanVersion>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
jsonHandler<PlanVersion>(clientOptions.jsonMapper)

override fun createPlanVersion(
params: BetaCreatePlanVersionParams,
Expand All @@ -106,7 +107,7 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { createPlanVersionHandler.handle(it) }
.also {
Expand All @@ -119,7 +120,7 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien
}

private val fetchPlanVersionHandler: Handler<PlanVersion> =
jsonHandler<PlanVersion>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
jsonHandler<PlanVersion>(clientOptions.jsonMapper)

override fun fetchPlanVersion(
params: BetaFetchPlanVersionParams,
Expand All @@ -144,7 +145,7 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { fetchPlanVersionHandler.handle(it) }
.also {
Expand All @@ -157,7 +158,7 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien
}

private val setDefaultPlanVersionHandler: Handler<Plan> =
jsonHandler<Plan>(clientOptions.jsonMapper).withErrorHandler(errorHandler)
jsonHandler<Plan>(clientOptions.jsonMapper)

override fun setDefaultPlanVersion(
params: BetaSetDefaultPlanVersionParams,
Expand All @@ -178,7 +179,7 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien
return request
.thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) }
.thenApply { response ->
response.parseable {
errorHandler.handle(response).parseable {
response
.use { setDefaultPlanVersionHandler.handle(it) }
.also {
Expand Down
Loading