Skip to content

Commit 9d09bfa

Browse files
committed
global probe remote listener
1 parent b0399b3 commit 9d09bfa

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

src/jvmMain/kotlin/spp/protocol/extend/TCPServiceFrameParser.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,14 @@ class TCPServiceFrameParser(val vertx: Vertx, val socket: NetSocket) : Handler<A
6868
socket
6969
)
7070
} else {
71-
FrameHelper.sendFrame(
72-
BridgeEventType.SEND.name.lowercase(),
73-
frame.getString("replyAddress"),
74-
JsonObject.mapFrom(it.cause()),
71+
val replyException = it.cause() as ReplyException
72+
FrameHelper.writeFrame(
73+
JsonObject()
74+
.put("type", BridgeEventType.SEND.name.lowercase())
75+
.put("address", frame.getString("replyAddress"))
76+
.put("failureCode", replyException.failureCode())
77+
.put("failureType", replyException.failureType().name)
78+
.put("message", replyException.message),
7579
socket
7680
)
7781
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Source++, the open-source live coding platform.
3+
* Copyright (C) 2022 CodeBrig, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published
7+
* by the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
package spp.protocol.util
19+
20+
import io.vertx.serviceproxy.ServiceException
21+
import spp.protocol.service.error.LiveInstrumentException
22+
23+
object ServiceExceptionConverter {
24+
25+
fun fromEventBusException(exception: String): ServiceException {
26+
return if (exception.startsWith("EventBusException")) {
27+
var exceptionType = exception.substringAfter("EventBusException:")
28+
exceptionType = exceptionType.substringBefore("[")
29+
var exceptionParams = exception.substringAfter("[")
30+
exceptionParams = exceptionParams.substringBefore("]")
31+
val exceptionMessage = exception.substringAfter("]: ").trim { it <= ' ' }
32+
if (LiveInstrumentException::class.java.simpleName == exceptionType) {
33+
LiveInstrumentException(
34+
LiveInstrumentException.ErrorType.valueOf(exceptionParams),
35+
exceptionMessage
36+
).toEventBusException()
37+
} else {
38+
throw UnsupportedOperationException(exceptionType)
39+
}
40+
} else {
41+
throw IllegalArgumentException(exception)
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)