Ensure errors thrown by RED.events handlers don't percolate up

This commit is contained in:
Nick O'Leary 2016-09-05 23:09:33 +01:00
parent 765f0393b0
commit 1f24fcb364
1 changed files with 7 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/**
* Copyright 2015 IBM Corp.
* Copyright 2015, 2016 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -35,7 +35,12 @@
function emit(evt,arg) {
if (handlers[evt]) {
for (var i=0;i<handlers[evt].length;i++) {
handlers[evt][i](arg);
try {
handlers[evt][i](arg);
} catch(err) {
console.log("RED.events.emit error: ["+evt+"] "+(err.toString()));
console.log(err);
}
}
}