Fix #5452

Fixes #5452 by moving the try-catch into the function that generates the sequences rather than wrapping the lazy generation.