Crash Handler
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
1448
|
||||
1451
|
||||
+9
-5
@@ -12482,15 +12482,15 @@
|
||||
</f>
|
||||
<meta><m n=":keep"/></meta>
|
||||
</execAsync>
|
||||
<refreshAssets public="1" set="method" line="204" static="1">
|
||||
<refreshAssets public="1" set="method" line="205" static="1">
|
||||
<f a=""><x path="Void"/></f>
|
||||
<meta><m n=":keep"/></meta>
|
||||
</refreshAssets>
|
||||
<initTransition public="1" set="method" line="211" static="1">
|
||||
<initTransition public="1" set="method" line="212" static="1">
|
||||
<f a=""><x path="Void"/></f>
|
||||
<meta><m n=":keep"/></meta>
|
||||
</initTransition>
|
||||
<onStateSwitch set="method" line="222" static="1">
|
||||
<onStateSwitch set="method" line="223" static="1">
|
||||
<f a="newState">
|
||||
<c path="flixel.FlxState"/>
|
||||
<x path="Void"/>
|
||||
@@ -66130,9 +66130,9 @@
|
||||
<c path="cpp.RawConstPointer"><c path="discord_rpc.JoinRequest"/></c>
|
||||
<x path="Void"/>
|
||||
</f></_onRequest>
|
||||
<__touch get="inline" set="null" expr=""1.670677951e+012"" line="22" static="1">
|
||||
<__touch get="inline" set="null" expr=""1.670707736e+012"" line="22" static="1">
|
||||
<c path="String"/>
|
||||
<meta><m n=":value"><e>"1.670677951e+012"</e></m></meta>
|
||||
<meta><m n=":value"><e>"1.670707736e+012"</e></m></meta>
|
||||
</__touch>
|
||||
<meta>
|
||||
<m n=":directlyUsed"/>
|
||||
@@ -129782,6 +129782,10 @@
|
||||
</f></loadAnimatedGraphic>
|
||||
<meta><m n=":directlyUsed"/></meta>
|
||||
</class>
|
||||
<class path="funkin.system.CrashHandler" params="" file="source/funkin/system/CrashHandler.hx">
|
||||
<init public="1" set="method" line="4" static="1"><f a=""><x path="Void"/></f></init>
|
||||
<meta><m n=":directlyUsed"/></meta>
|
||||
</class>
|
||||
<class path="funkin.system.DiscordClient" params="" file="source/funkin/system/Discord.hx" module="funkin.system.Discord">
|
||||
<shutdown public="1" set="method" line="33" static="1"><f a=""><x path="Void"/></f></shutdown>
|
||||
<onReady set="method" line="38" static="1"><f a=""><x path="Void"/></f></onReady>
|
||||
|
||||
@@ -49,6 +49,10 @@ class CoolUtil
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function last<T>(array:Array<T>):T {
|
||||
return array[array.length - 1];
|
||||
}
|
||||
|
||||
public static function setFieldDefault<T>(v:Dynamic, name:String, defaultValue:T):T {
|
||||
if (Reflect.hasField(v, name)) {
|
||||
var f:Null<Dynamic> = Reflect.field(v, name);
|
||||
@@ -274,13 +278,6 @@ class CoolUtil
|
||||
return xml.att.resolve(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns last member of array
|
||||
*/
|
||||
public static function last<T>(array:Array<T>):T {
|
||||
return array[array.length-1];
|
||||
}
|
||||
|
||||
public static function loadFrames(path:String, Unique:Bool = false, Key:String = null):FlxFramesCollection {
|
||||
var noExt = Path.withoutExtension(path);
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package funkin.system;
|
||||
|
||||
import lime.system.System;
|
||||
import funkin.windows.WindowsAPI;
|
||||
import openfl.Lib;
|
||||
import openfl.events.UncaughtErrorEvent;
|
||||
import openfl.events.ErrorEvent;
|
||||
import openfl.errors.Error;
|
||||
import openfl.events.UncaughtErrorEvent;
|
||||
import haxe.CallStack;
|
||||
|
||||
class CrashHandler {
|
||||
public static function init() {
|
||||
Lib.current.loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, onError);
|
||||
}
|
||||
|
||||
public static function onError(e:UncaughtErrorEvent) {
|
||||
var m:String = e.error;
|
||||
if (Std.isOfType(e.error, Error)) {
|
||||
var err = cast(e.error, Error);
|
||||
m = '${err.message}';
|
||||
} else if (Std.isOfType(e.error, ErrorEvent)) {
|
||||
var err = cast(e.error, ErrorEvent);
|
||||
m = '${err.text}';
|
||||
}
|
||||
var stack = CallStack.exceptionStack();
|
||||
var stackLabel:String = "";
|
||||
for(e in stack) {
|
||||
switch(e) {
|
||||
case CFunction: stackLabel += "- Non-Haxe (C) Function";
|
||||
case Module(c): stackLabel += '- Module ${c}';
|
||||
case FilePos(parent, file, line, col):
|
||||
switch(parent) {
|
||||
case Method(cla, func):
|
||||
stackLabel += '- (${file}) ${cla.split(".").last()}.$func() - line $line';
|
||||
case _:
|
||||
stackLabel += '- (${file}) - line $line';
|
||||
}
|
||||
case LocalFunction(v):
|
||||
stackLabel += '- Local Function ${v}';
|
||||
case Method(cl, m):
|
||||
stackLabel += '- ${cl} - ${m}';
|
||||
}
|
||||
stackLabel += "\r\n";
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
WindowsAPI.showMessageBox("Codename Engine Crash Handler", 'Uncaught Error:$m\n\n$stackLabel');
|
||||
#if sys
|
||||
Sys.exit(1);
|
||||
#end
|
||||
}
|
||||
}
|
||||
@@ -133,6 +133,7 @@ class Main extends Sprite
|
||||
#end
|
||||
Paths.assetsTree = new AssetsLibraryList();
|
||||
|
||||
CrashHandler.init();
|
||||
Logs.init();
|
||||
Paths.init();
|
||||
ModsFolder.init();
|
||||
@@ -231,6 +232,6 @@ class Main extends Sprite
|
||||
|
||||
Paths.assetsTree.clearCache();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,17 @@ class WindowsAPI {
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a message box
|
||||
*/
|
||||
public static function showMessageBox(caption:String, message:String, icon:MessageBoxIcon = MSG_WARNING) {
|
||||
#if windows
|
||||
native.WinAPI.showMessageBox(caption, message, icon);
|
||||
#else
|
||||
lime.app.Application.current.window.alert(title, text);
|
||||
#end
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the console colors
|
||||
*/
|
||||
@@ -82,4 +93,11 @@ class WindowsAPI {
|
||||
var MAGENTA:ConsoleColor = 13;
|
||||
var YELLOW:ConsoleColor = 14;
|
||||
var WHITE:ConsoleColor = 15;
|
||||
}
|
||||
|
||||
@:enum abstract MessageBoxIcon(Int) {
|
||||
var MSG_ERROR:MessageBoxIcon = 0x00000010;
|
||||
var MSG_QUESTION:MessageBoxIcon = 0x00000020;
|
||||
var MSG_WARNING:MessageBoxIcon = 0x00000030;
|
||||
var MSG_INFORMATION:MessageBoxIcon = 0x00000040;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package native;
|
||||
|
||||
import funkin.windows.WindowsAPI.MessageBoxIcon;
|
||||
#if windows
|
||||
@:buildXml('
|
||||
<target id="haxe">
|
||||
@@ -168,5 +169,15 @@ class WinAPI {
|
||||
public static function clearScreen() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if windows
|
||||
@:functionCode('
|
||||
MessageBox(GetActiveWindow(), message, caption, icon | MB_SETFOREGROUND);
|
||||
')
|
||||
#end
|
||||
public static function showMessageBox(caption:String, message:String, icon:MessageBoxIcon = MSG_WARNING) {
|
||||
|
||||
}
|
||||
}
|
||||
#end
|
||||
Reference in New Issue
Block a user