Catch exceptions in main.

- guarantee output of error message and correct exit
Fix system.hh for case without HAVE_PETSC