cil_write_ast: improve error handling am: 6369bbbd96 am: b9e0d3d19c
am: 82b3984473

Change-Id: Iaedab42c1da718c56f99894583df595228fb35cc