From 66def9828a6b222909242113c7656134ce8d49b8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 05:30:45 +0000 Subject: [PATCH] chore(client)!: refactor exception structure and methods # Migration Previously you would access error JSON on an exception via `exception.error()._additionalProperties()`, which would return `Map`. Now you would access this via `exception.body()`, which returns `JsonValue`. You should no longer assume that the returned error JSON is an object. You can check via `exception.body().asObject()`. --- .../api/core/handlers/ErrorHandler.kt | 149 +++++++----------- .../api/errors/BadRequestException.kt | 78 ++++++++- .../api/errors/InternalServerException.kt | 93 ++++++++++- .../openlayer/api/errors/NotFoundException.kt | 74 ++++++++- .../openlayer/api/errors/OpenlayerError.kt | 82 ---------- .../api/errors/OpenlayerServiceException.kt | 22 +-- .../api/errors/PermissionDeniedException.kt | 78 ++++++++- .../api/errors/RateLimitException.kt | 78 ++++++++- .../api/errors/UnauthorizedException.kt | 78 ++++++++- .../errors/UnexpectedStatusCodeException.kt | 94 ++++++++++- .../errors/UnprocessableEntityException.kt | 78 ++++++++- .../services/async/CommitServiceAsyncImpl.kt | 4 +- .../InferencePipelineServiceAsyncImpl.kt | 4 +- .../services/async/ProjectServiceAsyncImpl.kt | 4 +- .../commits/TestResultServiceAsyncImpl.kt | 4 +- .../DataServiceAsyncImpl.kt | 4 +- .../inferencepipelines/RowServiceAsyncImpl.kt | 4 +- .../TestResultServiceAsyncImpl.kt | 4 +- .../async/projects/CommitServiceAsyncImpl.kt | 4 +- .../InferencePipelineServiceAsyncImpl.kt | 4 +- .../storage/PresignedUrlServiceAsyncImpl.kt | 4 +- .../services/blocking/CommitServiceImpl.kt | 4 +- .../blocking/InferencePipelineServiceImpl.kt | 4 +- .../services/blocking/ProjectServiceImpl.kt | 4 +- .../blocking/commits/TestResultServiceImpl.kt | 4 +- .../inferencepipelines/DataServiceImpl.kt | 4 +- .../inferencepipelines/RowServiceImpl.kt | 4 +- .../TestResultServiceImpl.kt | 4 +- .../blocking/projects/CommitServiceImpl.kt | 4 +- .../projects/InferencePipelineServiceImpl.kt | 4 +- .../storage/PresignedUrlServiceImpl.kt | 4 +- .../api/services/ErrorHandlingTest.kt | 56 ++++--- 32 files changed, 763 insertions(+), 277 deletions(-) delete mode 100644 openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerError.kt diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/ErrorHandler.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/ErrorHandler.kt index 5e442089..52ca7bb6 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/ErrorHandler.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/core/handlers/ErrorHandler.kt @@ -1,125 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + @file:JvmName("ErrorHandler") package com.openlayer.api.core.handlers import com.fasterxml.jackson.databind.json.JsonMapper -import com.openlayer.api.core.http.Headers +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.http.HttpResponse import com.openlayer.api.core.http.HttpResponse.Handler import com.openlayer.api.errors.BadRequestException import com.openlayer.api.errors.InternalServerException import com.openlayer.api.errors.NotFoundException -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.errors.PermissionDeniedException import com.openlayer.api.errors.RateLimitException import com.openlayer.api.errors.UnauthorizedException import com.openlayer.api.errors.UnexpectedStatusCodeException import com.openlayer.api.errors.UnprocessableEntityException -import java.io.ByteArrayInputStream -import java.io.InputStream @JvmSynthetic -internal fun errorHandler(jsonMapper: JsonMapper): Handler { - val handler = jsonHandler(jsonMapper) +internal fun errorHandler(jsonMapper: JsonMapper): Handler { + val handler = jsonHandler(jsonMapper) - return object : Handler { - override fun handle(response: HttpResponse): OpenlayerError = + return object : Handler { + override fun handle(response: HttpResponse): JsonValue = try { handler.handle(response) } catch (e: Exception) { - OpenlayerError.builder().build() + JsonMissing.of() } } } @JvmSynthetic -internal fun Handler.withErrorHandler(errorHandler: Handler): Handler = +internal fun Handler.withErrorHandler(errorHandler: Handler): Handler = object : Handler { - override fun handle(response: HttpResponse): T { + override fun handle(response: HttpResponse): T = when (val statusCode = response.statusCode()) { - in 200..299 -> { - return this@withErrorHandler.handle(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 -> this@withErrorHandler.handle(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 = this@buffered.statusCode() - - override fun headers(): Headers = this@buffered.headers() - - override fun body(): InputStream = ByteArrayInputStream(body) - - override fun close() = this@buffered.close() } -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/BadRequestException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/BadRequestException.kt index fdd01aa2..ea4fa913 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/BadRequestException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/BadRequestException.kt @@ -1,6 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.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?) : + OpenlayerServiceException("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) = cause(cause.getOrNull()) -class BadRequestException(headers: Headers, body: String, error: OpenlayerError) : - OpenlayerServiceException(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, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/InternalServerException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/InternalServerException.kt index ba8c9119..aca354d8 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/InternalServerException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/InternalServerException.kt @@ -1,10 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InternalServerException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : OpenlayerServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InternalServerException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InternalServerException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(internalServerException: InternalServerException) = apply { + statusCode = internalServerException.statusCode + headers = internalServerException.headers + body = internalServerException.body + cause = internalServerException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + 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) = cause(cause.getOrNull()) -class InternalServerException( - statusCode: Int, - headers: Headers, - body: String, - error: OpenlayerError, -) : OpenlayerServiceException(statusCode, headers, body, error) + /** + * Returns an immutable instance of [InternalServerException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InternalServerException = + InternalServerException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/NotFoundException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/NotFoundException.kt index d47b79cc..7bbae3bb 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/NotFoundException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/NotFoundException.kt @@ -1,6 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class NotFoundException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OpenlayerServiceException("404: $body", cause) { + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + override fun statusCode(): Int = 404 + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [NotFoundException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [NotFoundException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(notFoundException: NotFoundException) = apply { + headers = notFoundException.headers + body = notFoundException.body + cause = notFoundException.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) = cause(cause.getOrNull()) -class NotFoundException(headers: Headers, body: String, error: OpenlayerError) : - OpenlayerServiceException(404, headers, body, error) + /** + * Returns an immutable instance of [NotFoundException]. + * + * 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(): NotFoundException = + NotFoundException(checkRequired("headers", headers), checkRequired("body", body), cause) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerError.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerError.kt deleted file mode 100644 index c6b6dad2..00000000 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerError.kt +++ /dev/null @@ -1,82 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.openlayer.api.errors - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.openlayer.api.core.ExcludeMissing -import com.openlayer.api.core.JsonValue -import com.openlayer.api.core.NoAutoDetect -import com.openlayer.api.core.immutableEmptyMap -import com.openlayer.api.core.toImmutable -import java.util.Objects - -@NoAutoDetect -class OpenlayerError -@JsonCreator -private constructor( - @JsonAnyGetter - @ExcludeMissing - @JsonAnySetter - @get:JvmName("additionalProperties") - val additionalProperties: Map = immutableEmptyMap() -) { - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [OpenlayerError]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [OpenlayerError]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(openlayerError: OpenlayerError) = apply { - additionalProperties = openlayerError.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [OpenlayerError]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): OpenlayerError = OpenlayerError(additionalProperties.toImmutable()) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is OpenlayerError && additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(additionalProperties) /* spotless:on */ - - override fun toString() = "OpenlayerError{additionalProperties=$additionalProperties}" -} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerServiceException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerServiceException.kt index f170186e..69a2cf0b 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerServiceException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/OpenlayerServiceException.kt @@ -1,23 +1,17 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.http.Headers abstract class OpenlayerServiceException -@JvmOverloads -constructor( - private val statusCode: Int, - private val headers: Headers, - private val body: String, - private val error: OpenlayerError, - message: String = "$statusCode: $error", - cause: Throwable? = null, -) : OpenlayerException(message, cause) { - - fun statusCode(): Int = statusCode +protected constructor(message: String, cause: Throwable? = null) : + OpenlayerException(message, cause) { - fun headers(): Headers = headers + abstract fun statusCode(): Int - fun body(): String = body + abstract fun headers(): Headers - fun error(): OpenlayerError = error + abstract fun body(): JsonValue } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/PermissionDeniedException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/PermissionDeniedException.kt index 72a01e62..f931e74c 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/PermissionDeniedException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/PermissionDeniedException.kt @@ -1,6 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PermissionDeniedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OpenlayerServiceException("403: $body", cause) { + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + override fun statusCode(): Int = 403 + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PermissionDeniedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PermissionDeniedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(permissionDeniedException: PermissionDeniedException) = apply { + headers = permissionDeniedException.headers + body = permissionDeniedException.body + cause = permissionDeniedException.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) = cause(cause.getOrNull()) -class PermissionDeniedException(headers: Headers, body: String, error: OpenlayerError) : - OpenlayerServiceException(403, headers, body, error) + /** + * Returns an immutable instance of [PermissionDeniedException]. + * + * 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(): PermissionDeniedException = + PermissionDeniedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/RateLimitException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/RateLimitException.kt index 067918e5..fa8e4df3 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/RateLimitException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/RateLimitException.kt @@ -1,6 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class RateLimitException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OpenlayerServiceException("429: $body", cause) { + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + override fun statusCode(): Int = 429 + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [RateLimitException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RateLimitException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(rateLimitException: RateLimitException) = apply { + headers = rateLimitException.headers + body = rateLimitException.body + cause = rateLimitException.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) = cause(cause.getOrNull()) -class RateLimitException(headers: Headers, body: String, error: OpenlayerError) : - OpenlayerServiceException(429, headers, body, error) + /** + * Returns an immutable instance of [RateLimitException]. + * + * 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(): RateLimitException = + RateLimitException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnauthorizedException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnauthorizedException.kt index 893dbf8f..3a0c1cda 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnauthorizedException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnauthorizedException.kt @@ -1,6 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnauthorizedException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OpenlayerServiceException("401: $body", cause) { + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + override fun statusCode(): Int = 401 + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnauthorizedException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnauthorizedException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unauthorizedException: UnauthorizedException) = apply { + headers = unauthorizedException.headers + body = unauthorizedException.body + cause = unauthorizedException.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) = cause(cause.getOrNull()) -class UnauthorizedException(headers: Headers, body: String, error: OpenlayerError) : - OpenlayerServiceException(401, headers, body, error) + /** + * Returns an immutable instance of [UnauthorizedException]. + * + * 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(): UnauthorizedException = + UnauthorizedException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnexpectedStatusCodeException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnexpectedStatusCodeException.kt index b4cab62c..e8ed72b9 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnexpectedStatusCodeException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnexpectedStatusCodeException.kt @@ -1,10 +1,92 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnexpectedStatusCodeException +private constructor( + private val statusCode: Int, + private val headers: Headers, + private val body: JsonValue, + cause: Throwable?, +) : OpenlayerServiceException("$statusCode: $body", cause) { + + override fun statusCode(): Int = statusCode + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [UnexpectedStatusCodeException]. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnexpectedStatusCodeException]. */ + class Builder internal constructor() { + + private var statusCode: Int? = null + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unexpectedStatusCodeException: UnexpectedStatusCodeException) = apply { + statusCode = unexpectedStatusCodeException.statusCode + headers = unexpectedStatusCodeException.headers + body = unexpectedStatusCodeException.body + cause = unexpectedStatusCodeException.cause + } + + fun statusCode(statusCode: Int) = apply { this.statusCode = statusCode } + + 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) = cause(cause.getOrNull()) -class UnexpectedStatusCodeException( - statusCode: Int, - headers: Headers, - body: String, - error: OpenlayerError, -) : OpenlayerServiceException(statusCode, headers, body, error) + /** + * Returns an immutable instance of [UnexpectedStatusCodeException]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .statusCode() + * .headers() + * .body() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnexpectedStatusCodeException = + UnexpectedStatusCodeException( + checkRequired("statusCode", statusCode), + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnprocessableEntityException.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnprocessableEntityException.kt index 940a85d8..ceeaf6b6 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnprocessableEntityException.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/errors/UnprocessableEntityException.kt @@ -1,6 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + package com.openlayer.api.errors +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.checkRequired import com.openlayer.api.core.http.Headers +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class UnprocessableEntityException +private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) : + OpenlayerServiceException("422: $body", cause) { + + override fun headers(): Headers = headers + + override fun body(): JsonValue = body + + override fun statusCode(): Int = 422 + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UnprocessableEntityException]. + * + * The following fields are required: + * ```java + * .headers() + * .body() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnprocessableEntityException]. */ + class Builder internal constructor() { + + private var headers: Headers? = null + private var body: JsonValue? = null + private var cause: Throwable? = null + + @JvmSynthetic + internal fun from(unprocessableEntityException: UnprocessableEntityException) = apply { + headers = unprocessableEntityException.headers + body = unprocessableEntityException.body + cause = unprocessableEntityException.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) = cause(cause.getOrNull()) -class UnprocessableEntityException(headers: Headers, body: String, error: OpenlayerError) : - OpenlayerServiceException(422, headers, body, error) + /** + * Returns an immutable instance of [UnprocessableEntityException]. + * + * 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(): UnprocessableEntityException = + UnprocessableEntityException( + checkRequired("headers", headers), + checkRequired("body", body), + cause, + ) + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt index 39799d61..6195c624 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/CommitServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -13,7 +14,6 @@ import com.openlayer.api.core.http.HttpResponse.Handler import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepareAsync -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.commits.CommitRetrieveParams import com.openlayer.api.models.commits.CommitRetrieveResponse import com.openlayer.api.services.async.commits.TestResultServiceAsync @@ -45,7 +45,7 @@ class CommitServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CommitServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val testResults: TestResultServiceAsync.WithRawResponse by lazy { TestResultServiceAsyncImpl.WithRawResponseImpl(clientOptions) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt index 809fc79f..d333e5e9 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.emptyHandler import com.openlayer.api.core.handlers.errorHandler @@ -16,7 +17,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepareAsync -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveResponse @@ -77,7 +77,7 @@ internal constructor(private val clientOptions: ClientOptions) : InferencePipeli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InferencePipelineServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val data: DataServiceAsync.WithRawResponse by lazy { DataServiceAsyncImpl.WithRawResponseImpl(clientOptions) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsyncImpl.kt index 14f66c6c..33b9d711 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/ProjectServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepareAsync -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.projects.ProjectCreateParams import com.openlayer.api.models.projects.ProjectCreateResponse import com.openlayer.api.models.projects.ProjectListParams @@ -61,7 +61,7 @@ class ProjectServiceAsyncImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ProjectServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val commits: CommitServiceAsync.WithRawResponse by lazy { CommitServiceAsyncImpl.WithRawResponseImpl(clientOptions) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsyncImpl.kt index 25422d17..8163f596 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/commits/TestResultServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async.commits import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -13,7 +14,6 @@ import com.openlayer.api.core.http.HttpResponse.Handler import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepareAsync -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.commits.testresults.TestResultListParams import com.openlayer.api.models.commits.testresults.TestResultListResponse import java.util.concurrent.CompletableFuture @@ -37,7 +37,7 @@ class TestResultServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TestResultServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsyncImpl.kt index a7b602a5..b3614235 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/DataServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async.inferencepipelines import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepareAsync -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.inferencepipelines.data.DataStreamParams import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse import java.util.concurrent.CompletableFuture @@ -38,7 +38,7 @@ class DataServiceAsyncImpl internal constructor(private val clientOptions: Clien class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DataServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val streamHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncImpl.kt index 14e43222..50b06e66 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/RowServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async.inferencepipelines import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepareAsync -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams import com.openlayer.api.models.inferencepipelines.rows.RowUpdateResponse import java.util.concurrent.CompletableFuture @@ -38,7 +38,7 @@ class RowServiceAsyncImpl internal constructor(private val clientOptions: Client class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RowServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsyncImpl.kt index 996335c6..c0ea06fa 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencepipelines/TestResultServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async.inferencepipelines import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -13,7 +14,6 @@ import com.openlayer.api.core.http.HttpResponse.Handler import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepareAsync -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.inferencepipelines.testresults.TestResultListParams import com.openlayer.api.models.inferencepipelines.testresults.TestResultListResponse import java.util.concurrent.CompletableFuture @@ -37,7 +37,7 @@ class TestResultServiceAsyncImpl internal constructor(private val clientOptions: class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TestResultServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt index 3960b323..0558d15b 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/CommitServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async.projects import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepareAsync -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.projects.commits.CommitCreateParams import com.openlayer.api.models.projects.commits.CommitCreateResponse import com.openlayer.api.models.projects.commits.CommitListParams @@ -47,7 +47,7 @@ class CommitServiceAsyncImpl internal constructor(private val clientOptions: Cli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CommitServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsyncImpl.kt index 357027bb..eebe0dcb 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/projects/InferencePipelineServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async.projects import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepareAsync -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateParams import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateResponse import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListParams @@ -47,7 +47,7 @@ internal constructor(private val clientOptions: ClientOptions) : InferencePipeli class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InferencePipelineServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsyncImpl.kt index 2a0390f5..eef0b53d 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/storage/PresignedUrlServiceAsyncImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.async.storage import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepareAsync -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateParams import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateResponse import java.util.concurrent.CompletableFuture @@ -38,7 +38,7 @@ class PresignedUrlServiceAsyncImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : PresignedUrlServiceAsync.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt index 57bfda49..98799c85 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/CommitServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -13,7 +14,6 @@ import com.openlayer.api.core.http.HttpResponse.Handler import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepare -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.commits.CommitRetrieveParams import com.openlayer.api.models.commits.CommitRetrieveResponse import com.openlayer.api.services.blocking.commits.TestResultService @@ -42,7 +42,7 @@ class CommitServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CommitService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val testResults: TestResultService.WithRawResponse by lazy { TestResultServiceImpl.WithRawResponseImpl(clientOptions) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt index cc013f6f..d2b9adbb 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.emptyHandler import com.openlayer.api.core.handlers.errorHandler @@ -16,7 +17,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepare -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.inferencepipelines.InferencePipelineDeleteParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveParams import com.openlayer.api.models.inferencepipelines.InferencePipelineRetrieveResponse @@ -72,7 +72,7 @@ class InferencePipelineServiceImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InferencePipelineService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val data: DataService.WithRawResponse by lazy { DataServiceImpl.WithRawResponseImpl(clientOptions) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectServiceImpl.kt index 4de2f6c5..354e63f8 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/ProjectServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepare -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.projects.ProjectCreateParams import com.openlayer.api.models.projects.ProjectCreateResponse import com.openlayer.api.models.projects.ProjectListParams @@ -60,7 +60,7 @@ class ProjectServiceImpl internal constructor(private val clientOptions: ClientO class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ProjectService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val commits: CommitService.WithRawResponse by lazy { CommitServiceImpl.WithRawResponseImpl(clientOptions) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceImpl.kt index f9bbc61f..2a5a5e91 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/commits/TestResultServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking.commits import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -13,7 +14,6 @@ import com.openlayer.api.core.http.HttpResponse.Handler import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepare -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.commits.testresults.TestResultListParams import com.openlayer.api.models.commits.testresults.TestResultListResponse @@ -36,7 +36,7 @@ class TestResultServiceImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TestResultService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataServiceImpl.kt index e7643803..2f1b4e10 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/DataServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking.inferencepipelines import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepare -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.inferencepipelines.data.DataStreamParams import com.openlayer.api.models.inferencepipelines.data.DataStreamResponse @@ -36,7 +36,7 @@ class DataServiceImpl internal constructor(private val clientOptions: ClientOpti class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DataService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val streamHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceImpl.kt index 085ddf73..0762fdb9 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/RowServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking.inferencepipelines import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepare -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.inferencepipelines.rows.RowUpdateParams import com.openlayer.api.models.inferencepipelines.rows.RowUpdateResponse @@ -36,7 +36,7 @@ class RowServiceImpl internal constructor(private val clientOptions: ClientOptio class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : RowService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultServiceImpl.kt index 32b10215..ca926f79 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencepipelines/TestResultServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking.inferencepipelines import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -13,7 +14,6 @@ import com.openlayer.api.core.http.HttpResponse.Handler import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepare -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.inferencepipelines.testresults.TestResultListParams import com.openlayer.api.models.inferencepipelines.testresults.TestResultListResponse @@ -36,7 +36,7 @@ class TestResultServiceImpl internal constructor(private val clientOptions: Clie class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : TestResultService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt index db0c3c0a..1342de0e 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/CommitServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking.projects import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepare -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.projects.commits.CommitCreateParams import com.openlayer.api.models.projects.commits.CommitCreateResponse import com.openlayer.api.models.projects.commits.CommitListParams @@ -46,7 +46,7 @@ class CommitServiceImpl internal constructor(private val clientOptions: ClientOp class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CommitService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceImpl.kt index 8603b8ee..194d911d 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/projects/InferencePipelineServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking.projects import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepare -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateParams import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineCreateResponse import com.openlayer.api.models.projects.inferencepipelines.InferencePipelineListParams @@ -46,7 +46,7 @@ class InferencePipelineServiceImpl internal constructor(private val clientOption class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : InferencePipelineService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceImpl.kt index aff6f743..76933320 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/storage/PresignedUrlServiceImpl.kt @@ -3,6 +3,7 @@ package com.openlayer.api.services.blocking.storage import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.JsonValue import com.openlayer.api.core.RequestOptions import com.openlayer.api.core.handlers.errorHandler import com.openlayer.api.core.handlers.jsonHandler @@ -14,7 +15,6 @@ import com.openlayer.api.core.http.HttpResponseFor import com.openlayer.api.core.http.json import com.openlayer.api.core.http.parseable import com.openlayer.api.core.prepare -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateParams import com.openlayer.api.models.storage.presignedurl.PresignedUrlCreateResponse @@ -37,7 +37,7 @@ class PresignedUrlServiceImpl internal constructor(private val clientOptions: Cl class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : PresignedUrlService.WithRawResponse { - private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ErrorHandlingTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ErrorHandlingTest.kt index 951d0b2d..bcc988e0 100644 --- a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ErrorHandlingTest.kt +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/ErrorHandlingTest.kt @@ -16,7 +16,6 @@ import com.openlayer.api.core.jsonMapper import com.openlayer.api.errors.BadRequestException import com.openlayer.api.errors.InternalServerException import com.openlayer.api.errors.NotFoundException -import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.errors.OpenlayerException import com.openlayer.api.errors.PermissionDeniedException import com.openlayer.api.errors.RateLimitException @@ -35,12 +34,9 @@ internal class ErrorHandlingTest { companion object { - private val ERROR: OpenlayerError = - OpenlayerError.builder() - .putAdditionalProperty("errorProperty", JsonValue.from("42")) - .build() + private val ERROR_JSON: JsonValue = JsonValue.from(mapOf("errorProperty" to "42")) - private val ERROR_JSON: ByteArray = jsonMapper().writeValueAsBytes(ERROR) + private val ERROR_JSON_BYTES: ByteArray = jsonMapper().writeValueAsBytes(ERROR_JSON) private const val HEADER_NAME: String = "Error-Header" @@ -65,7 +61,9 @@ internal class ErrorHandlingTest { val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + .willReturn( + status(400).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) ) val e = @@ -108,8 +106,8 @@ internal class ErrorHandlingTest { } assertThat(e.statusCode()).isEqualTo(400) - assertThat(e.error()).isEqualTo(ERROR) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test @@ -117,7 +115,9 @@ internal class ErrorHandlingTest { val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + .willReturn( + status(401).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) ) val e = @@ -160,8 +160,8 @@ internal class ErrorHandlingTest { } assertThat(e.statusCode()).isEqualTo(401) - assertThat(e.error()).isEqualTo(ERROR) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test @@ -169,7 +169,9 @@ internal class ErrorHandlingTest { val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + .willReturn( + status(403).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) ) val e = @@ -212,8 +214,8 @@ internal class ErrorHandlingTest { } assertThat(e.statusCode()).isEqualTo(403) - assertThat(e.error()).isEqualTo(ERROR) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test @@ -221,7 +223,9 @@ internal class ErrorHandlingTest { val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + .willReturn( + status(404).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) ) val e = @@ -264,8 +268,8 @@ internal class ErrorHandlingTest { } assertThat(e.statusCode()).isEqualTo(404) - assertThat(e.error()).isEqualTo(ERROR) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test @@ -273,7 +277,9 @@ internal class ErrorHandlingTest { val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + .willReturn( + status(422).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) ) val e = @@ -316,8 +322,8 @@ internal class ErrorHandlingTest { } assertThat(e.statusCode()).isEqualTo(422) - assertThat(e.error()).isEqualTo(ERROR) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test @@ -325,7 +331,9 @@ internal class ErrorHandlingTest { val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + .willReturn( + status(429).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) ) val e = @@ -368,8 +376,8 @@ internal class ErrorHandlingTest { } assertThat(e.statusCode()).isEqualTo(429) - assertThat(e.error()).isEqualTo(ERROR) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test @@ -377,7 +385,9 @@ internal class ErrorHandlingTest { val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + .willReturn( + status(500).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) ) val e = @@ -420,8 +430,8 @@ internal class ErrorHandlingTest { } assertThat(e.statusCode()).isEqualTo(500) - assertThat(e.error()).isEqualTo(ERROR) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test @@ -429,7 +439,9 @@ internal class ErrorHandlingTest { val dataService = client.inferencePipelines().data() stubFor( post(anyUrl()) - .willReturn(status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON)) + .willReturn( + status(999).withHeader(HEADER_NAME, HEADER_VALUE).withBody(ERROR_JSON_BYTES) + ) ) val e = @@ -472,8 +484,8 @@ internal class ErrorHandlingTest { } assertThat(e.statusCode()).isEqualTo(999) - assertThat(e.error()).isEqualTo(ERROR) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) + assertThat(e.body()).isEqualTo(ERROR_JSON) } @Test