examine err before res.