Return an error code to the os when an exception occurs.