Better error handling to avoid nodejs to quit