Works for me:
function Decoder(bytes, port) {
var error;
try {
console.log("Here we go!");
// should throw: 'myvar' is not defined
console.log(myvar);
}
catch (e) {
console.log(e);
error = e;
}
finally {
if (error) {
return {worksForMe: error};
}
return {oops: "exception not caught"};
}
}
This shows:
When not using try-catch then see also the MQTT error events as mentioned in Is there any documentation on payload functions?