-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNotFoundException.kt
More file actions
80 lines (63 loc) · 2.39 KB
/
Copy pathNotFoundException.kt
File metadata and controls
80 lines (63 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// File generated from our OpenAPI spec by Stainless.
package com.lithic.api.errors
import com.lithic.api.core.JsonValue
import com.lithic.api.core.checkRequired
import com.lithic.api.core.http.Headers
import com.lithic.api.core.jsonMapper
import java.util.Optional
import kotlin.jvm.optionals.getOrNull
class NotFoundException
private constructor(private val headers: Headers, private val body: JsonValue, cause: Throwable?) :
LithicServiceException(
"404: ${if (body.isMissing()) "Unknown" else jsonMapper().writeValueAsString(body)}",
cause,
) {
override fun statusCode(): Int = 404
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 [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<Throwable>) = cause(cause.getOrNull())
/**
* 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)
}
}