Checks against undefined response body

If res.body is undefined, conversion to string fails. It happens for example when an error occurs and debugging is enabled.