@@ -267,17 +267,21 @@ class LightModelServer @JvmOverloads constructor(val port: Int, val rootNodeProv
267
267
for (frame in incoming) {
268
268
when (frame) {
269
269
is Frame .Text -> {
270
- val json = frame.readText()
271
- LOG .trace { " incoming message: ${json.take(5000 )} " }
272
- val message = MessageFromClient .fromJson(json)
273
- message.query?.let { session.replaceQuery(it) }
274
- val ops = message.operations ? : emptyList()
275
- val response = if (ops.isNotEmpty()) {
276
- withContext(Dispatchers .Main ) { // write access in MPS is only allowed from EDT
277
- getArea().executeWrite { session.applyUpdate(ops, message.changeSetId) }
270
+ val response = try {
271
+ val json = frame.readText()
272
+ LOG .trace { " incoming message: ${json.take(5000 )} " }
273
+ val message = MessageFromClient .fromJson(json)
274
+ message.query?.let { session.replaceQuery(it) }
275
+ val ops = message.operations ? : emptyList()
276
+ if (ops.isNotEmpty()) {
277
+ withContext(Dispatchers .Main ) { // write access in MPS is only allowed from EDT
278
+ getArea().executeWrite { session.applyUpdate(ops, message.changeSetId) }
279
+ }
280
+ } else {
281
+ getArea().executeRead { session.applyUpdate(ops, message.changeSetId) }
278
282
}
279
- } else {
280
- getArea().executeRead { session.applyUpdate(ops, message.changeSetId) }
283
+ } catch (ex : Throwable ) {
284
+ MessageFromServer (exception = ExceptionData (ex))
281
285
}
282
286
send(response.toJson())
283
287
}
@@ -340,17 +344,13 @@ class LightModelServer @JvmOverloads constructor(val port: Int, val rootNodeProv
340
344
341
345
@Synchronized
342
346
fun applyUpdate (operations : List <OperationData >, changeSetId : ChangeSetId ? ): MessageFromServer {
343
- try {
344
- val updateSession = UpdateSession ()
345
- operations.forEach { updateSession.applyOperation(it) }
346
- return MessageFromServer (
347
- version = createUpdate(),
348
- replacedIds = updateSession.replacedIds,
349
- appliedChangeSet = changeSetId,
350
- )
351
- } catch (ex: Exception ) {
352
- return MessageFromServer (exception = ExceptionData (ex))
353
- }
347
+ val updateSession = UpdateSession ()
348
+ operations.forEach { updateSession.applyOperation(it) }
349
+ return MessageFromServer (
350
+ version = createUpdate(),
351
+ replacedIds = updateSession.replacedIds,
352
+ appliedChangeSet = changeSetId,
353
+ )
354
354
}
355
355
356
356
private inner class UpdateSession () {
0 commit comments