Skip to content

Commit

Permalink
Merge pull request #123 from muzzammilshahid/dealer-handle-err
Browse files Browse the repository at this point in the history
dealer: handle error message
  • Loading branch information
muzzammilshahid authored Aug 1, 2024
2 parents 7cf240a + 092e3f1 commit ee40e00
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/src/dealer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,22 @@ class Dealer {

var unregistered = Unregistered(message.requestID);
return MessageWithRecipient(unregistered, sessionID);
} else if (message is Error) {
if (message.msgType != Invocation.id) {
throw Exception("dealer: only expected to receive error in response to invocation");
}

var pending = _pendingCalls[message.requestID];
if (pending == null) {
throw Exception("dealer: no pending invocation for ${message.requestID}");
}

_pendingCalls.remove(message.requestID);

var errMessage = Error(Call.id, pending.requestID, message.uri,
args: message.args, kwargs: message.kwargs, details: message.details);

return MessageWithRecipient(errMessage, pending.callerID);
} else {
throw Exception("message type not supported");
}
Expand Down

0 comments on commit ee40e00

Please sign in to comment.