Skip to content

Commit 77820ad

Browse files
committed
Add more info to the library descriptor parsing exception
1 parent f06feb1 commit 77820ad

File tree

1 file changed

+16
-10
lines changed
  • jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries

1 file changed

+16
-10
lines changed

jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/libraries/Parsing.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ import org.jetbrains.kotlinx.jupyter.protocol.api.KernelLoggerFactory
99

1010
private val jsonParser = Json { ignoreUnknownKeys = true }
1111

12-
private inline fun <T> parseCatching(
13-
descriptor: T,
14-
parse: (T) -> LibraryDescriptor,
15-
): LibraryDescriptor =
16-
try {
17-
parse(descriptor)
18-
} catch (e: SerializationException) {
19-
throw ReplException("Error during library deserialization. Library descriptor text:\n$descriptor", e)
20-
}
21-
2212
fun parseLibraryDescriptor(json: String): LibraryDescriptor =
2313
parseCatching(json) {
2414
jsonParser.decodeFromString(it)
@@ -39,3 +29,19 @@ fun parseLibraryDescriptors(
3929
parseLibraryDescriptor(it.value)
4030
}
4131
}
32+
33+
private inline fun <T> parseCatching(
34+
descriptor: T,
35+
parse: (T) -> LibraryDescriptor,
36+
): LibraryDescriptor =
37+
try {
38+
parse(descriptor)
39+
} catch (e: SerializationException) {
40+
throw ReplException(
41+
"Error during library deserialization. " +
42+
"Read about library descriptor format at " +
43+
"https://github.com/Kotlin/kotlin-jupyter/blob/master/docs/libraries.md#creating-a-library-descriptor\n" +
44+
"Library descriptor text:\n$descriptor",
45+
e,
46+
)
47+
}

0 commit comments

Comments
 (0)