Fix some missing error handlings