55using System . Threading . Tasks ;
66using UnityEngine ;
77using PureScript ;
8+ using System . Runtime . InteropServices ;
9+
810public class TestException : MonoBehaviour
911{
1012 ExceptionTest other ;
1113
14+ [ DllImport ( "ScriptEngine" , EntryPoint = "OnExceptionIl2cpp" , CallingConvention = CallingConvention . Cdecl ) ]
15+ public static extern void RaiseIl2cppException ( string msg ) ;
16+
1217 private void Start ( )
1318 {
1419 Debug . LogError ( "##Start 1" ) ;
1520 other = new ExceptionTest ( ) ;
1621 Debug . LogError ( "##Start 2" ) ;
17- other . callback = OnCallback ;
22+ other . callback = TestCallbackException ;
1823 Debug . LogError ( "##Start 3" ) ;
24+ //Application.focusChanged += OnFocusNullPointException;
1925 Application . focusChanged += OnFocusCallbackException ;
2026 Debug . LogError ( "##Start 4" ) ;
2127 }
2228
2329 /*
2430 Exception: System.NullReferenceException: Object reference not set to an instance of an object.
25- * at PureScript.ExceptionTest.NullPointException () [0x00000] in <00000000000000000000000000000000>:0
31+ * at PureScript.ExceptionTest.NullPointException () [0x00000] in <00000000000000000000000000000000>:0
2632 at UnityBind.PureScript_ExceptionTest_NullPointException (System.Int32 thiz_h) [0x00000] in <00000000000000000000000000000000>:0
27- at (wrapper managed-to-native) System.Object.wrapper_native_00007FFA513268C0(int )
28- * at PureScript.ExceptionTest.NullPointException () [0x0000c ] in <8365f2ae61e94f83a867dc955d743bc6 >:0
29- at TestException.OnFocusNullPointException (System.Boolean focus) [0x00012] in <7bba8e115a884a978ebee1a64957c99e >:0
33+ at (wrapper managed-to-native) PureScript.ScriptEngine.CheckException( )
34+ * at PureScript.ExceptionTest.NullPointException () [0x00012 ] in <32aba121fea14339b39ae3ef7a81ab85 >:0
35+ at TestException.OnFocusNullPointException (System.Boolean focus) [0x00012] in <a78fd91ac283481f9b729fcc794fb0b0 >:0
3036 at UnityEngine.Application.InvokeFocusChanged (System.Boolean focus) [0x0000b] in <cf7fb9a754e74776ae71c25165ca083c>:0
3137 at (wrapper native-to-managed) UnityEngine.Application.InvokeFocusChanged(bool,System.Exception&)
3238 */
@@ -40,28 +46,39 @@ void OnFocusNullPointException(bool focus)
4046 }
4147 }
4248
43-
49+ /*
50+ Exception: System.Exception: System.Exception: This exception turn around ~~
51+ at TestException.TestCallbackException () [0x0000c] in <ae28305b9ad94cbf995b02f06babebda>:0
52+ at PureScript.ExceptionTest.Oncallback (System.Int32 arg0_h) [0x0000b] in <32aba121fea14339b39ae3ef7a81ab85>:0
53+ at PureScript.ScriptEngine.CheckException () [0x00000] in <00000000000000000000000000000000>:0
54+ at UnityBind.OnExceptionTest_callback (PureScript.ExceptionTest arg0) [0x00000] in <00000000000000000000000000000000>:0
55+ at System.Action.Invoke () [0x00000] in <00000000000000000000000000000000>:0
56+ * at PureScript.ExceptionTest.TestCallBack () [0x00000] in <00000000000000000000000000000000>:0
57+ at UnityBind.PureScript_ExceptionTest_TestCallBack (System.Int32 thiz_h) [0x00000] in <00000000000000000000000000000000>:0
58+ at (wrapper managed-to-native) PureScript.ScriptEngine.CheckException()
59+ * at PureScript.ExceptionTest.TestCallBack () [0x00012] in <32aba121fea14339b39ae3ef7a81ab85>:0
60+ at TestException.OnFocusCallbackException (System.Boolean focus) [0x00012] in <ae28305b9ad94cbf995b02f06babebda>:0
61+ at UnityEngine.Application.InvokeFocusChanged (System.Boolean focus) [0x0000b] in <cf7fb9a754e74776ae71c25165ca083c>:0
62+ at (wrapper native-to-managed) UnityEngine.Application.InvokeFocusChanged(bool,System.Exception&)
63+ */
4464 void OnFocusCallbackException ( bool focus )
4565 {
4666 if ( focus )
4767 {
48- try
49- {
50- Debug . LogError ( "##OnFocus 1" ) ;
51- other . TestCallBack ( ) ;
52- Debug . LogError ( "##OnFocus 2" ) ;
53- } catch ( Exception e )
54- {
55- Debug . LogError ( e . ToString ( ) ) ;
56- }
57-
68+ //RaiseMonoException("testException");
69+ //return;
70+
71+ Debug . LogError ( "##OnFocus 1" ) ;
72+ other . TestCallBack ( ) ;
73+ Debug . LogError ( "##OnFocus 2" ) ;
74+ return ;
5875 }
5976 }
6077
61- void OnCallback ( )
78+ void TestCallbackException ( )
6279 {
6380 Debug . LogError ( "##OnCallback 1" ) ;
64- throw new NullReferenceException ( "This exception turn around ~~" ) ;
81+ throw new Exception ( "This exception turn around ~~" ) ;
6582 Debug . LogError ( "##OnCallback 2" ) ;
6683 }
6784}
0 commit comments