Start of exception handling
use throwIO so the exception is thrown at the correct time