Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(gnolang): move Exception to frame.go #3596

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions gnovm/pkg/gnolang/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,30 @@ func toConstExpTrace(cte *ConstExpr) string {

return tv.T.String()
}

//----------------------------------------
// Exception

// Exception represents a panic that originates from a gno program.
type Exception struct {
// Value is the value passed to panic.
Value TypedValue
// Frame is used to reference the frame a panic occurred in so that recover() knows if the
// currently executing deferred function is able to recover from the panic.
Frame *Frame

Stacktrace Stacktrace
}

func (e Exception) Sprint(m *Machine) string {
return e.Value.Sprint(m)
}

// UnhandledPanicError represents an error thrown when a panic is not handled in the realm.
type UnhandledPanicError struct {
Descriptor string // Description of the unhandled panic.
}

func (e UnhandledPanicError) Error() string {
return e.Descriptor
}
24 changes: 0 additions & 24 deletions gnovm/pkg/gnolang/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,6 @@ import (
"github.com/gnolang/gno/tm2/pkg/store"
)

// Exception represents a panic that originates from a gno program.
type Exception struct {
// Value is the value passed to panic.
Value TypedValue
// Frame is used to reference the frame a panic occurred in so that recover() knows if the
// currently executing deferred function is able to recover from the panic.
Frame *Frame

Stacktrace Stacktrace
}

func (e Exception) Sprint(m *Machine) string {
return e.Value.Sprint(m)
}

// UnhandledPanicError represents an error thrown when a panic is not handled in the realm.
type UnhandledPanicError struct {
Descriptor string // Description of the unhandled panic.
}

func (e UnhandledPanicError) Error() string {
return e.Descriptor
}

//----------------------------------------
// Machine

Expand Down
Loading