From fdcbc11093ba282ba5889ceef32a19b7170b0394 Mon Sep 17 00:00:00 2001 From: Frenco Date: Thu, 4 Feb 2021 22:38:03 +0630 Subject: [PATCH] (fix) check if nextInvocation is null in exception closes #23 --- lib/runtime/runtime.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/runtime/runtime.dart b/lib/runtime/runtime.dart index 106d7474..70ec74cd 100644 --- a/lib/runtime/runtime.dart +++ b/lib/runtime/runtime.dart @@ -104,8 +104,9 @@ class Runtime { final context = Context.fromNextInvocation(nextInvocation); final func = _handlers[context.handler]; - if(func == null) { - throw RuntimeException('No handler with name "${context.handler}" registered in runtime!'); + if (func == null) { + throw RuntimeException( + 'No handler with name "${context.handler}" registered in runtime!'); } final event = Event.fromHandler(func.type, await nextInvocation.response); @@ -113,8 +114,10 @@ class Runtime { await _client.postInvocationResponse(result); } on Exception catch (error, stacktrace) { - await _client.postInvocationError( - nextInvocation.requestId, InvocationError(error, stacktrace)); + if (nextInvocation != null) { + await _client.postInvocationError( + nextInvocation.requestId, InvocationError(error, stacktrace)); + } } nextInvocation = null;