PennState/scim-client

HTTP and protocol errors are not nicely passed through SCIM client

Opened this issue · 0 comments

If OAuth2 authentication fails (or requires) re-authentication during a SCIM client call ... this error should be put into a SCIMError so that the message (from the entity body) and the status code are both available to the SCIM client library user.

As noted by the title change, this actually applies to any HTTP error that does not include an entity body with the JSON for a SCIMError. In this case, the unmarshaling error should not be returned but rather the HTTP status code (and maybe message) along with the plain text from the entity body should be put into an error and returned. The incorrect code is:

	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		var er ErrorResponse
		err = json.Unmarshal(body, &er)
		if err != nil {
			return err
		}
		return er
	}