Refactor check nodejs error msgs and return codes