mirror of
				https://github.com/node-red/node-red.git
				synced 2025-03-01 10:36:34 +00:00 
			
		
		
		
	Merge pull request #3346 from node-red/fix-stack-capture
Handle reporting error location when stack is truncated
This commit is contained in:
		| @@ -32,8 +32,14 @@ function wrapEventFunction(obj,func) { | ||||
|     return function(eventName, listener) { | ||||
|         if (deprecatedEvents.hasOwnProperty(eventName)) { | ||||
|             const log = require("@node-red/util").log; | ||||
|             const stack = (new Error().stack).split("\n")[2].split("(")[1].slice(0,-1); | ||||
|             log.warn(`[RED.events] Deprecated use of "${eventName}" event from "${stack}". Use "${deprecatedEvents[eventName]}" instead.`) | ||||
|  | ||||
|             const stack = (new Error().stack).split("\n"); | ||||
|             let location = "(unknown)" | ||||
|             // See https://github.com/node-red/node-red/issues/3292 | ||||
|             if (stack.length > 2) { | ||||
|                 location = stack[2].split("(")[1].slice(0,-1); | ||||
|             } | ||||
|             log.warn(`[RED.events] Deprecated use of "${eventName}" event from "${location}". Use "${deprecatedEvents[eventName]}" instead.`) | ||||
|         } | ||||
|         return events["_"+func].call(events,eventName,listener) | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user