File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
standalone/src/main/kotlin/gg/essential/universal/standalone/glfw Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 1+
2+ package gg.essential.universal.standalone.glfw
3+
4+ @Suppress(" MemberVisibilityCanBePrivate" , " CanBeParameter" )
5+ class GLFWException (
6+ val errorMessage : String ,
7+ val glfwErrorMessage : String? ,
8+ val glfwErrorCode : Int? ,
9+ ) : RuntimeException(" $errorMessage : $glfwErrorMessage${if (glfwErrorCode != null ) " (code $glfwErrorCode )" else " " } " )
Original file line number Diff line number Diff line change @@ -64,16 +64,16 @@ class GlfwWindow(
6464 ?.let { return @run it }
6565
6666 // Failed to create any context, fetch the error and throw
67- val message = MemoryStack .stackPush().use { stack ->
67+ val ( message, code) = MemoryStack .stackPush().use { stack ->
6868 val pointer = stack.mallocPointer(1 )
6969 val error = GLFW .glfwGetError(pointer)
7070 if (error != GLFW .GLFW_NO_ERROR ) {
71- " ${ MemoryUtil .memUTF8Safe(pointer.get(0 ))} (code $ error) "
71+ MemoryUtil .memUTF8Safe(pointer.get(0 )) to error
7272 } else {
73- " unknown error"
73+ " unknown error" to null
7474 }
7575 }
76- throw RuntimeException (" Failed to create the GLFW window: $ message" )
76+ throw GLFWException (" Failed to create the GLFW window" , message, code )
7777 }
7878
7979 init {
@@ -130,4 +130,4 @@ class GlfwWindow(
130130 override fun close () {
131131 GLFW .glfwDestroyWindow(glfwId)
132132 }
133- }
133+ }
You can’t perform that action at this time.
0 commit comments