Skip to content

Commit 5e37dbe

Browse files
webdev-supportsongqifuchangkun
authored
android: log JVM run error (#30)
See golang/go#26445 and golang/go#33254 Co-authored-by: songqifu <[email protected]> Co-authored-by: Changkun Ou <[email protected]>
1 parent 789f633 commit 5e37dbe

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

clipboard_android.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func read(t Format) (buf []byte, err error) {
3333
switch t {
3434
case FmtText:
3535
s := ""
36-
app.RunOnJVM(func(vm, env, ctx uintptr) error {
36+
if err := app.RunOnJVM(func(vm, env, ctx uintptr) error {
3737
cs := C.clipboard_read_string(C.uintptr_t(vm), C.uintptr_t(env), C.uintptr_t(ctx))
3838
if cs == nil {
3939
return nil
@@ -42,7 +42,9 @@ func read(t Format) (buf []byte, err error) {
4242
s = C.GoString(cs)
4343
C.free(unsafe.Pointer(cs))
4444
return nil
45-
})
45+
}); err != nil {
46+
return nil, err
47+
}
4648
return []byte(s), nil
4749
case FmtImage:
4850
return nil, errUnsupported
@@ -60,11 +62,13 @@ func write(t Format, buf []byte) (<-chan struct{}, error) {
6062
cs := C.CString(string(buf))
6163
defer C.free(unsafe.Pointer(cs))
6264

63-
app.RunOnJVM(func(vm, env, ctx uintptr) error {
65+
if err := app.RunOnJVM(func(vm, env, ctx uintptr) error {
6466
C.clipboard_write_string(C.uintptr_t(vm), C.uintptr_t(env), C.uintptr_t(ctx), cs)
6567
done <- struct{}{}
6668
return nil
67-
})
69+
}); err != nil {
70+
return nil, err
71+
}
6872
return done, nil
6973
case FmtImage:
7074
return nil, errUnsupported

0 commit comments

Comments
 (0)