Friday, September 1, 2017

Error reporting in the P/Invoke tool

Previously, if my P/Invoke command line tool encountered an error (like bad syntax from the user), the entire program would crash and exit, giving no feedback about what caused the problem other than the exception stack spew to the standard error stream.

In the interest of user-friendly error messages, today I added an exception handler that prints the current instruction number, current instruction text, and exception message when an exception is thrown as a result of processing an instruction. For parse errors, the parser also supplies the fragment currently being parsed (which can be smaller than the current instruction) and prints a caret pointing at the current position within that fragment.

No comments:

Post a Comment