You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Undefined Token: ..... from the ErrorMapper. I partially fixed this, with the following code, however it's not ideal as it doesn't directly show the source as you'd expect, however yields better results than the Undefined Token
constsafeConsole={log: typeofconsole!=="undefined"&&typeofconsole.log==="function" ? console.log : ()=>{},error: typeofconsole!=="undefined"&&typeofconsole.error==="function" ? console.error : ()=>{}};exportclassErrorMapper{privatestatic_consumer?: SourceMapConsumer;publicstaticgetconsumer(): SourceMapConsumer{if(!this._consumer){try{constmap=require("main.js.map");this._consumer=newSourceMapConsumer(map);}catch(e){safeConsole.error("Failed to initialize SourceMapConsumer",e);throwe;}}returnthis._consumer;}publicstaticcache: {[key: string]: string}={};publicstaticsourceMappedStackTrace(error: Error|string): string{conststack: string=errorinstanceofError ? (error.stackasstring) : error;if(this.cache.hasOwnProperty(stack)){returnthis.cache[stack];}constre=/^\s+at\s+(.+?\s+)?\(?([0-z._\-\\\/]+):(\d+):(\d+)\)?$/gm;letmatch: RegExpExecArray|null;letoutStack=error.toString();while((match=re.exec(stack))){if(match[2]==="main"){try{constpos=this.consumer.originalPositionFor({column: parseInt(match[4],10),line: parseInt(match[3],10)});if(pos.line!=null){if(pos.name){outStack+=`\n at ${pos.name} (${pos.source}:${pos.line}:${pos.column})`;}else{outStack+=`\n at ${match[1]||''}(${pos.source}:${pos.line}:${pos.column})`;}}else{break;}}catch(e){safeConsole.error("Error while mapping stack trace",e);break;}}else{break;}}this.cache[stack]=outStack;returnoutStack;}publicstaticwrapLoop(loop: ()=>void): ()=>void{return()=>{try{loop();}catch(e){if(einstanceofError){if("sim"inGame.rooms){safeConsole.log(`<span style='color:red'>Source maps don't work in the simulator - displaying original error<br>${_.escape(e.stack)}</span>`);}else{safeConsole.log(`<span style='color:red'>${_.escape(this.sourceMappedStackTrace(e))}</span>`);}}else{throwe;}}};}}
The text was updated successfully, but these errors were encountered:
I was continiously getting the error message
Undefined Token: .....
from the ErrorMapper. I partially fixed this, with the following code, however it's not ideal as it doesn't directly show the source as you'd expect, however yields better results than theUndefined Token
The text was updated successfully, but these errors were encountered: