1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

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

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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -35,7 +35,12 @@
function emit(evt,arg) { function emit(evt,arg) {
if (handlers[evt]) { if (handlers[evt]) {
for (var i=0;i<handlers[evt].length;i++) { 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);
}
} }
} }