JetBrains / skiko

Kotlin Multiplatform bindings to Skia
Apache License 2.0
1.82k stars 118 forks source link

More informative exception when missing platform dependency. #35

Closed jimgoog closed 3 years ago

jimgoog commented 3 years ago

Users get a NullPointerException if they forget to include the implementation(compose.desktop.currentOs) dependency. The NPE is really not very helpful in helping the user to identify the issue, and not really specific enough for ComposeDesktop to catch and rethrow. Surely a more informative error message could be thrown by skiko when a dependency is missing.

Caused by: java.lang.NullPointerException
    at java.base/java.io.Reader.<init>(Reader.java:167)
    at java.base/java.io.InputStreamReader.<init>(InputStreamReader.java:72)
    at org.jetbrains.skiko.Library.load(Library.kt:42)
    at org.jetbrains.skija.impl.Library$Companion.staticLoad(Library.kt:9)
    at org.jetbrains.skija.impl.Library.staticLoad(Library.kt)
    at org.jetbrains.skija.PictureRecorder.<clinit>(PictureRecorder.java:9)
    ... 18 more
jimgoog commented 3 years ago

That is to say, specifically, Skiko should check to see if the resource InputStream is null prior to passing it into the InputStreamReader, and if it is null, then throw a more helpful exception type indicating which resource is not found and that it is likely the result of a missing dependency.

olonho commented 3 years ago

Fixing in https://github.com/JetBrains/skiko/pull/39

okushnikov commented 1 month ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.