Replace a trigger_error with an exception.