We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
getOrThrow
1 parent c4d5fbd commit 44ab47aCopy full SHA for 44ab47a
openai-java-core/src/main/kotlin/com/openai/core/Utils.kt
@@ -9,13 +9,8 @@ import com.openai.errors.OpenAIInvalidDataException
9
import java.util.Collections
10
11
@JvmSynthetic
12
-internal fun <T : Any> T?.getOrThrow(name: String): T {
13
- if (this == null) {
14
- throw OpenAIInvalidDataException("'${name}' is not present")
15
- }
16
-
17
- return this
18
-}
+internal fun <T : Any> T?.getOrThrow(name: String): T =
+ this ?: throw OpenAIInvalidDataException("`${name}` is not present")
19
20
21
internal fun <T> List<T>.toUnmodifiable(): List<T> {
0 commit comments