vm: wrap cross-contract exceptions

This commit is contained in:
Anna Shaleva 2022-05-26 11:44:26 +03:00
parent a39b7cc3fd
commit a79c80cb8d
2 changed files with 11 additions and 4 deletions

View file

@ -1595,7 +1595,11 @@ func (v *VM) unloadContext(ctx *Context) {
if ctx.onUnload != nil {
err := ctx.onUnload(v.uncaughtException == nil)
if err != nil {
panic(fmt.Errorf("context unload callback failed: %w", err))
errMessage := fmt.Sprintf("context unload callback failed: %s", err)
if v.uncaughtException != nil {
errMessage = fmt.Sprintf("%s, uncaught exception: %s", errMessage, v.uncaughtException)
}
panic(errors.New(errMessage))
}
}
}