infrastructure for handling errors with exceptions