Skip to content

runtime: print error when panicking with error interface type - #300

Merged
deadprogram merged 1 commit into
devfrom
print-error
Apr 25, 2019
Merged

runtime: print error when panicking with error interface type#300
deadprogram merged 1 commit into
devfrom
print-error

Conversation

@aykevl

@aykevl aykevl commented Apr 24, 2019

Copy link
Copy Markdown
Member

No description provided.

@johanbrandhorst johanbrandhorst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread src/runtime/print.go
print(msg)
case error:
print(msg.Error())
default:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought, do we want to add a case fmt.Stringer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, panic() in the Go runtime also seems to accept that: https://play.golang.org/p/UOeakJdGX6_3

@aykevl

aykevl commented Apr 24, 2019

Copy link
Copy Markdown
Member Author

I have added some more cases, so that booleans, integers, and Stringer gets printed as well. This increases code size in some cases but it's not by a large margin and it is very useful for debugging. Also, if code size is a concern, it can be disabled using #299.

@deadprogram

Copy link
Copy Markdown
Member

Excellent work here. Merging.

@deadprogram
deadprogram merged commit 024eceb into dev Apr 25, 2019
@aykevl
aykevl deleted the print-error branch April 25, 2019 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants