Skip to content

Commit

Permalink
feat: don't print all exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
omarsy committed Jul 21, 2024
1 parent c7820cd commit 4ee0eeb
Show file tree
Hide file tree
Showing 7 changed files with 314 additions and 283 deletions.
1 change: 0 additions & 1 deletion gnovm/pkg/gnolang/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func toExprTrace(ex Expr) string {
}

func toTypeValueTrace(tv TypedValue) string {

switch val := tv.V.(type) {
case StringValue:
return val.String()
Expand Down
12 changes: 11 additions & 1 deletion gnovm/pkg/gnolang/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -2270,9 +2270,19 @@ func (m *Machine) String() string {
func (m *Machine) ExceptionsStacktrace() string {
var builder strings.Builder

for _, ex := range m.Exceptions {
i := 0
for i < len(m.Exceptions) {
ex := m.Exceptions[i]
builder.WriteString(fmt.Sprintf("panic %s\n", ex.Sprint(m)))
builder.WriteString(fmt.Sprintf("%s", ex.Stacktrace.String()))

if i == 0 && len(m.Exceptions) > 2 {
builder.WriteString(fmt.Sprintf("... %d panic(s) elided ...\n", len(m.Exceptions)-2))
i = len(m.Exceptions) - 1
continue
}

i++
}

return builder.String()
Expand Down
6 changes: 1 addition & 5 deletions gnovm/tests/files/panic0b.gno
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ func f() {
// main/files/panic0b.gno:14
// main<VPBlock(1,0)>()
// main/files/panic0b.gno:4
// panic second
// f<VPBlock(3,1)>()
// main/files/panic0b.gno:12
// main<VPBlock(1,0)>()
// main/files/panic0b.gno:4
// ... 1 panic(s) elided ...
// panic third
// f<VPBlock(3,1)>()
// main/files/panic0b.gno:9
Expand Down
2 changes: 1 addition & 1 deletion gnovm/tests/files/panic1.gno
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func main() {

// Stacktrace:
// panic here
// main<VPBlock(1,0)>()
// main<VPBlock(1,2)>()
// main/files/panic1.gno:22

// Error:
Expand Down
275 changes: 0 additions & 275 deletions gnovm/tests/files/panic2.gno

This file was deleted.

Loading

0 comments on commit 4ee0eeb

Please sign in to comment.