Skip to content

No exposed API to get full text of ErrMsg

In GHC version 7.10.3 it was possible to get the full text of an error message by using the functions ErrUtils.errMsgShortDoc and ErrUtils.errMsgExtraInfo.

But in GHC version 8.0.1 the code has changed. The full text of the error message is stored in the ErrMsg field ErrUtils.errMsgDoc, but this field is hidden, and there doesn't seem to be any API to access its contents.

The only workaround I can find is to use ErrUtils.pprLocErrMsg, and then strip out the first line containing the location info, and then manually unindent the 4-space "hang". This is quite ugly.

I suggest exporting ErrUtils.errMsgDoc, and then for that to be useful the fields of ErrUtils.ErrDoc will also be needed. Additionally, ErrUtils.formatErrDoc could be a nice bonus to have (and if exported would lessen the need for the ErrDoc fields).

The GHC API changes on every GHC release, so since backwards compatibility is not an issue, it would seem that there is no need to have a carefully exposed API, and there is no danger in liberally exporting stuff that clients could potentially find useful.

Thank you

Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component GHC API
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information