Skip to content

Commit

Permalink
(fix) check if nextInvocation is null in exception
Browse files Browse the repository at this point in the history
closes awslabs#23
  • Loading branch information
frencojobs committed Feb 4, 2021
1 parent bf47059 commit fdcbc11
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/runtime/runtime.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,20 @@ class Runtime<T> {
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);
final result = await func.handler(context, event);

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;
Expand Down

0 comments on commit fdcbc11

Please sign in to comment.