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.49.1"
".": "0.50.0"
}
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 0.50.0 (2025-03-19)

Full Changelog: [v0.49.1...v0.50.0](https://github.com/orbcorp/orb-java/compare/v0.49.1...v0.50.0)

### ⚠ BREAKING CHANGES

* **client:** refactor exception structure and methods ([#357](https://github.com/orbcorp/orb-java/issues/357))

### Bug Fixes

* compilation error ([287236c](https://github.com/orbcorp/orb-java/commit/287236c510b6351aa98f68abce900ad40f824537))


### Chores

* **client:** refactor exception structure and methods ([#357](https://github.com/orbcorp/orb-java/issues/357)) ([adc2898](https://github.com/orbcorp/orb-java/commit/adc28986adf95bb668ba4b4176fcd3c4b3507ca6))
* **internal:** codegen related update ([#356](https://github.com/orbcorp/orb-java/issues/356)) ([56e24bf](https://github.com/orbcorp/orb-java/commit/56e24bf8cdaf22d81e15d59bd0d5c2611729050e))
* **internal:** refactor enum query param serialization ([#353](https://github.com/orbcorp/orb-java/issues/353)) ([06904bf](https://github.com/orbcorp/orb-java/commit/06904bf13668ca9cb0cc9713a12c1b21811dbaa1))
* **internal:** version bump ([#354](https://github.com/orbcorp/orb-java/issues/354)) ([8d4d3e1](https://github.com/orbcorp/orb-java/commit/8d4d3e1e02c9547ad12254a8057294ff9c98de79))

## 0.49.1 (2025-03-18)

Full Changelog: [v0.49.0...v0.49.1](https://github.com/orbcorp/orb-java/compare/v0.49.0...v0.49.1)
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/0.49.1)
[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.50.0)

<!-- 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:0.49.1")
implementation("com.withorb.api:orb-java:0.50.0")
```

### Maven
Expand All @@ -28,7 +28,7 @@ implementation("com.withorb.api:orb-java:0.49.1")
<dependency>
<groupId>com.withorb.api</groupId>
<artifactId>orb-java</artifactId>
<version>0.49.1</version>
<version>0.50.0</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 = "0.49.1" // x-release-please-version
version = "0.50.0" // x-release-please-version
}
6 changes: 3 additions & 3 deletions buildSrc/src/main/kotlin/orb.kotlin.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ kotlin {
"-nowarn",
)
jvmTarget.set(JvmTarget.JVM_1_8)
languageVersion.set(KotlinVersion.KOTLIN_1_8)
apiVersion.set(KotlinVersion.KOTLIN_1_8)
coreLibrariesVersion = "1.8.0"
languageVersion.set(KotlinVersion.KOTLIN_1_9)
apiVersion.set(KotlinVersion.KOTLIN_1_9)
coreLibrariesVersion = "1.9.20"
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,125 +1,84 @@
// File generated from our OpenAPI spec by Stainless.

@file:JvmName("ErrorHandler")

package com.withorb.api.core.handlers

import com.fasterxml.jackson.databind.json.JsonMapper
import com.withorb.api.core.http.Headers
import com.withorb.api.core.JsonMissing
import com.withorb.api.core.JsonValue
import com.withorb.api.core.http.HttpResponse
import com.withorb.api.core.http.HttpResponse.Handler
import com.withorb.api.errors.BadRequestException
import com.withorb.api.errors.InternalServerException
import com.withorb.api.errors.NotFoundException
import com.withorb.api.errors.OrbError
import com.withorb.api.errors.PermissionDeniedException
import com.withorb.api.errors.RateLimitException
import com.withorb.api.errors.UnauthorizedException
import com.withorb.api.errors.UnexpectedStatusCodeException
import com.withorb.api.errors.UnprocessableEntityException
import java.io.ByteArrayInputStream
import java.io.InputStream

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

return object : Handler<OrbError> {
override fun handle(response: HttpResponse): OrbError =
return object : Handler<JsonValue> {
override fun handle(response: HttpResponse): JsonValue =
try {
handler.handle(response)
} catch (e: Exception) {
OrbError.builder().build()
JsonMissing.of()
}
}
}

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

private fun HttpResponse.buffered(): HttpResponse {
val body = body().readBytes()

return object : HttpResponse {
override fun statusCode(): Int = [email protected]()

override fun headers(): Headers = [email protected]()

override fun body(): InputStream = ByteArrayInputStream(body)

override fun close() = [email protected]()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,80 @@
// File generated from our OpenAPI spec by Stainless.

package com.withorb.api.errors

import com.withorb.api.core.JsonValue
import com.withorb.api.core.checkRequired
import com.withorb.api.core.http.Headers
import java.util.Optional
import kotlin.jvm.optionals.getOrNull

class BadRequestException
private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) :
OrbServiceException("400: $body", cause) {

override fun headers(): Headers = headers

override fun body(): JsonValue = body

override fun statusCode(): Int = 400

fun toBuilder() = Builder().from(this)

companion object {

/**
* Returns a mutable builder for constructing an instance of [BadRequestException].
*
* The following fields are required:
* ```java
* .headers()
* .body()
* ```
*/
@JvmStatic fun builder() = Builder()
}

/** A builder for [BadRequestException]. */
class Builder internal constructor() {

private var headers: Headers? = null
private var body: JsonValue? = null
private var cause: Throwable? = null

@JvmSynthetic
internal fun from(badRequestException: BadRequestException) = apply {
headers = badRequestException.headers
body = badRequestException.body
cause = badRequestException.cause
}

fun headers(headers: Headers) = apply { this.headers = headers }

fun body(body: JsonValue) = apply { this.body = body }

fun cause(cause: Throwable?) = apply { this.cause = cause }

/** Alias for calling [Builder.cause] with `cause.orElse(null)`. */
fun cause(cause: Optional<Throwable>) = cause(cause.getOrNull())

class BadRequestException(headers: Headers, body: String, error: OrbError) :
OrbServiceException(400, headers, body, error)
/**
* Returns an immutable instance of [BadRequestException].
*
* Further updates to this [Builder] will not mutate the returned instance.
*
* The following fields are required:
* ```java
* .headers()
* .body()
* ```
*
* @throws IllegalStateException if any required field is unset.
*/
fun build(): BadRequestException =
BadRequestException(
checkRequired("headers", headers),
checkRequired("body", body),
cause,
)
}
}
Loading
Loading