-
Notifications
You must be signed in to change notification settings - Fork 77
Error Reporting
This is a guide for rascal developers on how to report errors to the user.
There are only 2 kinds of errors:
- errors the user should see
- errors only a rascal developer should see
- User: develops in rascal using the plugin.
- Developer: develops in java to extend rascal.
Always write to the evaluator.getStdErr()
stream. Getting a reference to the evaluator is often just a .
away.
Either to use println
, printf
, or format
to trigger the auto flushing, or manually flush
the stream after you report an error.
- Function called from console: the error will print in the console
- Function called as a callback (vis-framework, ide-contributions): the error will always print in the output window
Always send the exception to Activator.log(msg, exception)
, (no need for the .getInstance()
call). Or if you are just debugging, send it to System.err
.
It will be reported to the errors view, which is not part of the default rascal perspective. So never report an error to this if the user might be interested in the fact that the code failed.
Note: we do not have a good story yet for users of the user. But since we split the messages between the stdOut
and stdErr
, there might be a clean solution for this.