generated from ShadowMario/FNF-PsychEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
80 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package funkin.backend.handlers; | ||
|
||
#if CRASH_HANDLER | ||
import lime.app.Application; | ||
import openfl.events.UncaughtErrorEvent; | ||
import haxe.CallStack; | ||
import haxe.io.Path; | ||
import sys.FileSystem; | ||
import sys.io.File; | ||
import sys.io.Process; | ||
#end | ||
|
||
class CrashHandler | ||
{ | ||
#if CRASH_HANDLER | ||
public static function onCrash(e:UncaughtErrorEvent):Void | ||
{ | ||
var errMsg:String = ""; | ||
var path:String; | ||
final callStack:Array<StackItem> = CallStack.exceptionStack(true); | ||
final dateNow:String = Date.now().toString().replace(" ", "_").replace(":", "'"); | ||
|
||
path = './crash/${Application.current.meta.get('file')}_$dateNow.txt'; | ||
trace(path); | ||
|
||
for (stackItem in callStack) | ||
{ | ||
switch (stackItem) | ||
{ | ||
case FilePos(s, file, line, column): | ||
errMsg += file + " (line " + line + ")\n"; | ||
default: | ||
Sys.println(stackItem); | ||
} | ||
} | ||
|
||
errMsg += "\nUncaught Error: " | ||
+ e.error | ||
+ "\nPlease report this error to the GitHub page:" | ||
+ EngineData.engineData.repository | ||
+ "\n\n---------------------------------------------------------\n> Crash Handler written by: sqirra-rng"; | ||
|
||
if (!FileSystem.exists("./crash/")) | ||
FileSystem.createDirectory("./crash/"); | ||
|
||
File.saveContent(path, errMsg + "\n"); | ||
|
||
Sys.println(errMsg); | ||
Sys.println("Crash dump saved in " + Path.normalize(path)); | ||
|
||
Application.current.window.alert(errMsg, "Error!"); | ||
#if DISCORD_ALLOWED | ||
DiscordClient.shutdown(); | ||
#end | ||
Sys.exit(1); | ||
} | ||
#end | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters