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

Fix #1399: Always report error message on PanicsWithError mismatch #1400

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

olivergondza
Copy link

Summary

Always report error message on PanicsWithError error message mismatch.

Changes

Add Error message field to the failure message, that reports panicErr.Error() IFF it panicked with an error its message is different from expected.

Motivation

Better defect localization in case of nested errors causing panic.

Before:

Error: func (assert.PanicTestFunc)(0x627a80) should panic with error message:	"at the disco"
	Panic value:	&errors.joinError{errs:[]error{(*errors.errorString)(0xc0000a1540), (*errors.errorString)(0xc0000a1550)}}
	Panic stack:	goroutine 19 [running]:
	...

After:

Error: func (assert.PanicTestFunc)(0x627b20) should panic with error message:	"at the disco"
	Panic value:	&errors.joinError{errs:[]error{(*errors.errorString)(0xc000065550), (*errors.errorString)(0xc000065560)}}
	Error message:	"wrapped err msg\nother err msg"
	Panic stack:	goroutine 6 [running]:
	...

Related issues

Closes #1399

@dolmen dolmen added pkg-assert Change related to package testify/assert enhancement labels Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted pkg-assert Change related to package testify/assert
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PanicsWithError does not report error message for complex errors
2 participants