Skip to content

Commit

Permalink
fix: throw decode error to force disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
kalinkrustev committed Sep 18, 2017
1 parent f6af754 commit 44369da
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions ndc.js
Expand Up @@ -683,20 +683,11 @@ NDC.prototype.decode = function(buffer, $meta, context) {

var fn = parsers[command.method];
if (typeof fn === 'function') {
try {
merge(message, fn.apply(parsers, tokens));
} catch (e) {
$meta.mtid = 'error';
message.type = e.type;
message.message = e.message;
if (!e.type) { // capture stack for unexpected errors
message.stack = e.stack;
}
}
merge(message, fn.apply(parsers, tokens));
} else {
$meta.mtid = 'error';
message.type = 'aptra.parser';
message.message = 'No parser found for message: ' + command.method;
var e = new Error('No parser found for message: ' + command.method);
e.type = 'aptra.decode';
throw e;
}
message.tokens = tokens;
} else {
Expand Down

0 comments on commit 44369da

Please sign in to comment.