7
7
*/
8
8
9
9
#include " channel.hpp"
10
+ #include " internals.hpp"
10
11
11
12
namespace rtc ::impl {
12
13
13
14
void Channel::triggerOpen () {
14
15
mOpenTriggered = true ;
15
- openCallback ();
16
+ try {
17
+ openCallback ();
18
+ } catch (const std::exception &e) {
19
+ PLOG_WARNING << " Uncaught exception in callback: " << e.what ();
20
+ }
16
21
flushPendingMessages ();
17
22
}
18
23
19
- void Channel::triggerClosed () { closedCallback (); }
24
+ void Channel::triggerClosed () {
25
+ try {
26
+ closedCallback ();
27
+ } catch (const std::exception &e) {
28
+ PLOG_WARNING << " Uncaught exception in callback: " << e.what ();
29
+ }
30
+ }
20
31
21
- void Channel::triggerError (string error) { errorCallback (std::move (error)); }
32
+ void Channel::triggerError (string error) {
33
+ try {
34
+ errorCallback (std::move (error));
35
+ } catch (const std::exception &e) {
36
+ PLOG_WARNING << " Uncaught exception in callback: " << e.what ();
37
+ }
38
+ }
22
39
23
40
void Channel::triggerAvailable (size_t count) {
24
- if (count == 1 )
25
- availableCallback ();
41
+ if (count == 1 ) {
42
+ try {
43
+ availableCallback ();
44
+ } catch (const std::exception &e) {
45
+ PLOG_WARNING << " Uncaught exception in callback: " << e.what ();
46
+ }
47
+ }
26
48
27
49
flushPendingMessages ();
28
50
}
29
51
30
52
void Channel::triggerBufferedAmount (size_t amount) {
31
53
size_t previous = bufferedAmount.exchange (amount);
32
54
size_t threshold = bufferedAmountLowThreshold.load ();
33
- if (previous > threshold && amount <= threshold)
34
- bufferedAmountLowCallback ();
55
+ if (previous > threshold && amount <= threshold) {
56
+ try {
57
+ bufferedAmountLowCallback ();
58
+ } catch (const std::exception &e) {
59
+ PLOG_WARNING << " Uncaught exception in callback: " << e.what ();
60
+ }
61
+ }
35
62
}
36
63
37
64
void Channel::flushPendingMessages () {
@@ -43,7 +70,11 @@ void Channel::flushPendingMessages() {
43
70
if (!next)
44
71
break ;
45
72
46
- messageCallback (*next);
73
+ try {
74
+ messageCallback (*next);
75
+ } catch (const std::exception &e) {
76
+ PLOG_WARNING << " Uncaught exception in callback: " << e.what ();
77
+ }
47
78
}
48
79
}
49
80
0 commit comments