Raise the right type of exception