Skip to content

Commit

Permalink
handle rejected promise in wgpu.await for cogentcore/core#1414
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoreilly committed Jan 18, 2025
1 parent 3809548 commit 3dd1436
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions wgpu/util_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package wgpu

import (
"log/slog"
"syscall/js"
"unsafe"
)
Expand Down Expand Up @@ -36,6 +37,10 @@ func await(promise js.Value) js.Value {
promise.Call("then", js.FuncOf(func(this js.Value, args []js.Value) any {
result <- args[0]
return nil
}), js.FuncOf(func(this js.Value, args []js.Value) any {
slog.Error("wgpu.await: promise rejected", "reason", args[0])
result <- js.Null()
return nil
}))
return <-result
}
Expand Down

0 comments on commit 3dd1436

Please sign in to comment.