replace definition of error with errorWithStackTrace

Herbert Valerio Riedel hvr at gnu.org
Mon Dec 1 09:34:27 UTC 2014


On 2014-12-01 at 05:08:12 +0100, Carter Schonwald wrote:
> http://hackage.haskell.org/package/base-4.7.0.1/docs/GHC-Stack.html#v:errorWithStackTrace
>
> has been in GHC for for >=1 major version,
> and for normal builds, acts just like error, BUT, when an error is thrown
> in a profiled build, it appends a stack trace with some basic source
> location data to the end of the error message!

I'm only a bit worried this may cause problems for code which catch
pure exceptions via `evaluate` and expect to recover the string passed to 'error'
by deconstructing the 'ErrorCall'...

  -- |This is thrown when the user calls 'error'. The @String@ is the
  -- argument given to 'error'.
  newtype ErrorCall = ErrorCall String
      deriving (Eq, Ord, Typeable, Exception)

at the very least you'd need to adapt the documentation of 'ErrorCall'


More information about the Libraries mailing list