Skip to content

Commit 45242b0

Browse files
Removed stack parsing it was not reliable on all JS engines
1 parent 35d0a3f commit 45242b0

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

scripts/_GameMaker.js

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -158,41 +158,16 @@ function yyUnhandledExceptionHandler( event )
158158
game_end(-1);
159159
} // end if
160160
else {
161-
// Create a regular expression pattern to split error stack string.
162-
const regexPattern = new RegExp("\n\\s*?at");
163-
164161
let error = event.error;
165-
const message = error.message;
166-
167-
// Split the error stack string into an array of call stack entries and remove leading/trailing spaces.
168-
// The first entry, usually a message or irrelevant info, is omitted.
169-
const stacktrace = error.stack
170-
.split(regexPattern)
171-
.map(entry => entry.trim())
172-
.slice(1);
173-
174-
// Attempt to parse the first call stack entry to identify the script where the error originated.
175-
// The script name is assumed to be the substring before the first space in the entry.
176-
let script = "";
177-
if (stacktrace.length > 0) {
178-
const firstEntry = stacktrace[0];
179-
const firstSpaceIndex = firstEntry.indexOf(' ');
180-
if (firstSpaceIndex !== -1) {
181-
script = firstEntry.substring(0, firstSpaceIndex);
182-
} else {
183-
script = firstEntry;
184-
}
185-
}
186162

187163
// Construct a GML struct to encapsulate the error details.
188164
let errorStruct = { }
189165
errorStruct.__type = "___struct___";
190166
errorStruct.__yyIsGMLObject = true;
191167

192168
// Add error details to the struct with a "gml" prefix for each member.
193-
errorStruct.gmlmessage = message;
194-
errorStruct.gmlstacktrace = stacktrace;
195-
errorStruct.gmlscript = script;
169+
errorStruct.gmlmessage = error.message;
170+
errorStruct.gmlstacktrace = error.stack;
196171

197172
// Pass the error struct to the custom error handler
198173
var ret = g_GMLUnhandledExceptionHandler( undefined, undefined, errorStruct );

0 commit comments

Comments
 (0)