Skip to content

Commit 44ab47a

Browse files
stainless-botStainless Bot
authored andcommitted
style(internal): make getOrThrow terse and consistent
chore: unknown commit message
1 parent c4d5fbd commit 44ab47a

File tree

1 file changed

+2
-7
lines changed
  • openai-java-core/src/main/kotlin/com/openai/core

1 file changed

+2
-7
lines changed

openai-java-core/src/main/kotlin/com/openai/core/Utils.kt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@ import com.openai.errors.OpenAIInvalidDataException
99
import java.util.Collections
1010

1111
@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-
}
12+
internal fun <T : Any> T?.getOrThrow(name: String): T =
13+
this ?: throw OpenAIInvalidDataException("`${name}` is not present")
1914

2015
@JvmSynthetic
2116
internal fun <T> List<T>.toUnmodifiable(): List<T> {

0 commit comments

Comments
 (0)