MCPcopy Create free account
hub / github.com/Whiley/WhileyCompiler / PrintStreamErrorHandler

Class PrintStreamErrorHandler

src/main/java/wyc/Compiler.java:331–348  ·  view source on GitHub ↗

A super simplistic error handler which is used for writing error messages to a given output stream (e.g. stdout). @author David J. Pearce

Source from the content-addressed store, hash-verified

329 *
330 */
331 public static class PrintStreamErrorHandler implements MailBox<SyntaxError> {
332 private final PrintStream output;
333
334 public PrintStreamErrorHandler(PrintStream output) {
335 this.output = output;
336 }
337
338 @Override
339 public void send(SyntaxError marker) {
340 // Identify enclosing source file
341 String filename = marker.getSource().toString() + ".whiley";
342 // Determine the source-file span for the given syntactic marker.
343 Syntactic.Span span = marker.getTarget().getAncestor(AbstractCompilationUnit.Attribute.Span.class);
344 // print the error message
345 output.println(filename + "|" + span.getStart() + "|" + span.getEnd() + "|" + marker.getErrorCode() + "|"
346 + marker.getMessage().replace("\n", "\\n"));
347 }
348 }
349}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected