-
Notifications
You must be signed in to change notification settings - Fork 77
Error Reporting
DavyLandman edited this page Sep 20, 2012
·
6 revisions
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.
- Write to the
evaluator.getStdErr()
stream. Getting a reference to the evaluator is often just a.
away. Either useprintln
,printf
, orformat
to trigger the auto flushing, or manuallyflush
the stream after you report an error. - Throw a rascal exception
throw new Throw()
Make sure you are not the highest method in the chain (IDE contributions, visualisation framework, or the shell itself)
- 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.