If generation fails due to some error, the generated file is left empty. This is a problem as it will break builds, but will also break the generation next time (if generating into the same source dir) because the package becomes unparseable.
Modifications to the file system should be made as a very last step when everything succeeded already.