Clean up the error handling a bit; the exception type is moved to Panic, and a new exception for panics has been added.