[utils] better error message and clean up