Add an exception handler to main

This solves #560. Also, failure to load a file is now a semantically meaningful error object.