Improve an error message.

See #1397.
Show the error message only if the error actually occurred.