Skip to content

Commit

Permalink
Merge pull request #3392 from onflow/supun/deterministic-errors
Browse files Browse the repository at this point in the history
Remove stacktrace from errors
  • Loading branch information
SupunS authored Jun 4, 2024
2 parents 904c0d3 + 6bcef81 commit b10c60b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions runtime/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package errors

import (
"fmt"
"runtime/debug"

"golang.org/x/xerrors"
)
Expand Down Expand Up @@ -142,8 +141,7 @@ func (e MemoryError) Error() string {
//
// NOTE: This error is not used for errors occur due to bugs in a user-provided program.
type UnexpectedError struct {
Err error
Stack []byte
Err error
}

var _ InternalError = UnexpectedError{}
Expand All @@ -152,15 +150,13 @@ func (UnexpectedError) IsInternalError() {}

func NewUnexpectedError(message string, arg ...any) UnexpectedError {
return UnexpectedError{
Err: fmt.Errorf(message, arg...),
Stack: debug.Stack(),
Err: fmt.Errorf(message, arg...),
}
}

func NewUnexpectedErrorFromCause(err error) UnexpectedError {
return UnexpectedError{
Err: err,
Stack: debug.Stack(),
Err: err,
}
}

Expand All @@ -169,7 +165,7 @@ func (e UnexpectedError) Unwrap() error {
}

func (e UnexpectedError) Error() string {
return fmt.Sprintf("internal error: %s\n%s", e.Err.Error(), e.Stack)
return fmt.Sprintf("internal error: %s", e.Err.Error())
}

// DefaultUserError is the default implementation of UserError interface.
Expand Down

0 comments on commit b10c60b

Please sign in to comment.