Skip to content

Commit 2042b37

Browse files
authored
Merge pull request #428 from YoYoGames/gmb-4437-unhandle-exception-fix
Function `exception_unhandled_handler` fixed on HTML5
2 parents dd9ed14 + 45242b0 commit 2042b37

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

scripts/_GameMaker.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,20 @@ function yyUnhandledExceptionHandler( event )
158158
game_end(-1);
159159
} // end if
160160
else {
161-
var ret = g_GMLUnhandledExceptionHandler( undefined, undefined, event.error );
162-
game_end( ret );
161+
let error = event.error;
162+
163+
// Construct a GML struct to encapsulate the error details.
164+
let errorStruct = { }
165+
errorStruct.__type = "___struct___";
166+
errorStruct.__yyIsGMLObject = true;
167+
168+
// Add error details to the struct with a "gml" prefix for each member.
169+
errorStruct.gmlmessage = error.message;
170+
errorStruct.gmlstacktrace = error.stack;
171+
172+
// Pass the error struct to the custom error handler
173+
var ret = g_GMLUnhandledExceptionHandler( undefined, undefined, errorStruct );
174+
game_end( ret );
163175
}
164176
debugger;
165177
return false;

0 commit comments

Comments
 (0)