We should log here why the generation fails.

Taking an input stream is a bit dubious? It could be:

* not at position zero when we start reading
* another thread could be reading concurrently
* caller might not realise we're reading through it

Is there a way to make sure we have a new stream that only this method is using?