add missing error handling and unify log