generator: Catch exceptions