File tree Expand file tree Collapse file tree 1 file changed +23
-7
lines changed
OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/threading Expand file tree Collapse file tree 1 file changed +23
-7
lines changed Original file line number Diff line number Diff line change 1
1
package com.onesignal.common.threading
2
2
3
+ import com.onesignal.debug.internal.logging.Logging
3
4
import kotlinx.coroutines.Dispatchers
4
5
import kotlinx.coroutines.runBlocking
5
6
import kotlinx.coroutines.withContext
@@ -41,11 +42,16 @@ fun suspendifyBlocking(block: suspend () -> Unit) {
41
42
*/
42
43
fun suspendifyOnMain (block : suspend () -> Unit ) {
43
44
thread {
44
- runBlocking {
45
- withContext(Dispatchers .Main ) {
46
- block()
45
+ try {
46
+ runBlocking {
47
+ withContext(Dispatchers .Main ) {
48
+ block()
49
+ }
47
50
}
48
51
}
52
+ catch (e: Exception ) {
53
+ Logging .error(" Exception on thread with switch to main" , e)
54
+ }
49
55
}
50
56
}
51
57
@@ -60,8 +66,13 @@ fun suspendifyOnThread(
60
66
block : suspend () -> Unit ,
61
67
) {
62
68
thread(priority = priority) {
63
- runBlocking {
64
- block()
69
+ try {
70
+ runBlocking {
71
+ block()
72
+ }
73
+ }
74
+ catch (e: Exception ) {
75
+ Logging .error(" Exception on thread" , e)
65
76
}
66
77
}
67
78
}
@@ -78,8 +89,13 @@ fun suspendifyOnThread(
78
89
block : suspend () -> Unit ,
79
90
) {
80
91
thread(name = name, priority = priority) {
81
- runBlocking {
82
- block()
92
+ try {
93
+ runBlocking {
94
+ block()
95
+ }
96
+ }
97
+ catch (e: Exception ) {
98
+ Logging .error(" Exception on thread '${name} '" , e)
83
99
}
84
100
}
85
101
}
You can’t perform that action at this time.
0 commit comments