diff --git a/lib/src/main/java/de/kuschku/libquassel/session/ProtocolHandler.kt b/lib/src/main/java/de/kuschku/libquassel/session/ProtocolHandler.kt index dfb1d84a51a6506ddf7fca16940d77ad580d4ecb..6a0a404b7ef388cf2a2770b802521400c8d5f39b 100644 --- a/lib/src/main/java/de/kuschku/libquassel/session/ProtocolHandler.kt +++ b/lib/src/main/java/de/kuschku/libquassel/session/ProtocolHandler.kt @@ -30,6 +30,7 @@ import de.kuschku.libquassel.quassel.syncables.interfaces.ISyncableObject import de.kuschku.libquassel.quassel.syncables.interfaces.invokers.Invokers import de.kuschku.libquassel.util.compatibility.LoggingHandler.Companion.log import de.kuschku.libquassel.util.compatibility.LoggingHandler.LogLevel.DEBUG +import de.kuschku.libquassel.util.compatibility.LoggingHandler.LogLevel.ERROR import java.io.Closeable abstract class ProtocolHandler( @@ -117,30 +118,34 @@ abstract class ProtocolHandler( open fun onInitStatusChanged(progress: Int, total: Int) {} override fun handle(f: SignalProxyMessage.SyncMessage): Boolean { - val obj = objectStorage.get(f.className, f.objectName) ?: if (isInitializing) { - syncQueue.add(f) - return true - } else null - - obj?.let { - val initQueue = toInit[it] - if (initQueue != null) { - initQueue.add(f) + try { + val obj = objectStorage.get(f.className, f.objectName) ?: if (isInitializing) { + syncQueue.add(f) return true - } + } else null + + obj?.let { + val initQueue = toInit[it] + if (initQueue != null) { + initQueue.add(f) + return true + } - val invoker = Invokers.get(ProtocolSide.CLIENT, f.className) - ?: throw IllegalArgumentException("Invalid classname: ${f.className}") - try { - currentCallClass = f.className - currentCallInstance = f.objectName - currentCallSlot = f.slotName - invoker.invoke(it, f.slotName, f.params) - } finally { - currentCallClass = "" - currentCallInstance = "" - currentCallSlot = "" + val invoker = Invokers.get(ProtocolSide.CLIENT, f.className) + ?: throw IllegalArgumentException("Invalid classname: ${f.className}") + try { + currentCallClass = f.className + currentCallInstance = f.objectName + currentCallSlot = f.slotName + invoker.invoke(it, f.slotName, f.params) + } finally { + currentCallClass = "" + currentCallInstance = "" + currentCallSlot = "" + } } + } catch (e: Exception) { + log(ERROR, "ProtocolHandler", "Exception occurred while processing $f", e) } return true }