Created
June 15, 2016 09:17
-
-
Save pjc0247/9fe1fb79ee938e4c22e0de35dfb0d415 to your computer and use it in GitHub Desktop.
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
public void AddExceptionHandler() | |
{ | |
// 유니티 메인 스레드가 아닌 다른 스레드에서 발생한 익셉션은 여기로 핸들링됩니다. | |
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | |
#pragma warning disable 0618 | |
// 유니티 스레드에서 발생된 익셉션은 여기로 핸들링됩니다. | |
UnityEngine.Application.RegisterLogCallback((condition, stackTrace, type) => | |
{ | |
if (type != LogType.Exception) | |
return; | |
SendLog(condition, stackTrace); | |
}); | |
#pragma warning restore 0618 | |
} | |
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) | |
{ | |
if (e.ExceptionObject is Exception == false) | |
return; | |
var ex = e.ExceptionObject as Exception; | |
SendLog(ex.Message, ex.StackTrace); | |
} | |
private void SendLog(string msg, string stackTrace) | |
{ | |
// 익셉션 로그를 저장하거나 / 서버로 전송한다 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment