Tests and implementation for the two types of exception thrown by execute.