Use error class for error messages

Makes it easier for parser functions like `#iferror` to detect errors (and less duplication).