cil_write_ast: improve error handling
am: 6369bbbd96

Change-Id: If8ef55553795cc0899ed9694b1085375896ac108