When source document not valid the generation throws unhandled exception. Need handle exception and print error message.