google / googletest

GoogleTest - Google Testing and Mocking Framework
https://google.github.io/googletest/
BSD 3-Clause "New" or "Revised" License
33.79k stars 10k forks source link

[#4387] Better exception printing for multi-line exceptions. #4403

Closed avrdan closed 5 months ago

avrdan commented 8 months ago

Solution for multi-line exceptions:

Examples

New line after each segment:

C++ exception with description 
> Error: 22000
> Error while communicating with S3
> DETAIL: aws-s3-bucket-name: mybucket
> INTERNAL DETAIL: aws-s3-bucket-name: mybucket
thrown in the test body.

Default behavior if no \n chars detected:

C++ exception with description
> Error: 22000 Error while communicating with S3 DETAIL: aws-s3-bucket-name: mybucket INTERNAL DETAIL: aws-s3-bucket-name: mybucket
thrown in the test body.

For more info please see my comment on https://github.com/google/googletest/issues/4387

avrdan commented 8 months ago

This branch contains two commits, I made 2 separate pull requests for the 2 separate issues. Sorry for tracking against the wrong branch... I think this one can be closed and the others can be merge candidates.

derekmauro commented 5 months ago

The team discussed this idea and decided not to accept it. It is a valid style choice, but we would prefer to preserve exact error messages.