@@ -197,9 +197,20 @@ public object Interpret( CilboxProxy ths, object [] parametersIn )
197197 try
198198 {
199199 ret = InterpretInner ( stackBuffer , parameters ) . AsObject ( ) ;
200- } catch ( Exception e )
200+ }
201+ catch ( Exception e )
201202 {
202203 parentClass . box . InterpreterExit ( ) ;
204+
205+ if ( e is CilboxUnhandledInterpretedException uhe )
206+ {
207+ // strip the throwee just in case, and re-throw a normal runtime exception
208+ string exceptionTypeName = uhe . Throwee ? . GetType ( ) . FullName ?? "null" ;
209+ string reason = $ "Exception of type { exceptionTypeName } was unhandled in interpreted code";
210+ parentClass . box . DisableWithReason ( reason ) ; // CilboxUnhandledInterpretedException bypasses the box disable
211+ throw new CilboxInterpreterRuntimeException ( reason , uhe . ClassName , uhe . MethodName , uhe . PC ) ;
212+ }
213+
203214 Debug . Log ( e . ToString ( ) ) ;
204215 throw ;
205216 }
@@ -1541,10 +1552,7 @@ private StackElement InterpretInner( ArraySegment<StackElement> stackBufferIn, A
15411552 catch ( Exception e )
15421553 {
15431554 string fullError = $ "Breakwarn: { e . ToString ( ) } Class: { parentClass . className } , Function: { methodName } , Bytecode: { pc } ";
1544- Debug . LogError ( fullError ) ;
1545- box . disabledReason = fullError ;
1546- box . disabled = true ;
1547- //box.InterpreterExit();
1555+ box . DisableWithReason ( fullError ) ;
15481556
15491557 if ( e is CilboxInterpreterRuntimeException )
15501558 {
@@ -2328,6 +2336,14 @@ void Update()
23282336 {
23292337 usSpentLastFrame = Interlocked . Exchange ( ref interpreterAccountingCumulitiveTicks , 0 ) / interpreterTicksInUs ;
23302338 }
2339+
2340+ internal void DisableWithReason ( string reason )
2341+ {
2342+ Debug . LogError ( reason ) ;
2343+ this . disabledReason = reason ;
2344+ this . disabled = true ;
2345+ //this.InterpreterExit();
2346+ }
23312347 }
23322348
23332349
@@ -3025,10 +3041,11 @@ public enum ImportFunctionID
30253041 Update ,
30263042 Start ,
30273043 Awake ,
3028- OnTriggerEnter ,
3029- OnTriggerExit ,
30303044 OnEnable ,
30313045 OnDisable ,
3046+ OnDestroy ,
3047+ OnTriggerEnter ,
3048+ OnTriggerExit ,
30323049 OnCollisionEnter ,
30333050 OnCollisionExit
30343051 }
0 commit comments