This improves the error handling of a HEAD request response. It avoids trying to parse the body entirely. To handle the error, you can still check for a *gitlab.ErrorResponse:
_, _, err := gitlabClient.RepositoryFiles.GetFileMetaData(1, "not-there.txt", &gitlab.GetFileMetaDataOptions{Ref: gitlab.Ptr("main")})
if err != nil {
var errResp *gitlab.ErrorResponse
if errors.As(err, &errResp) {
log.Println(errResp.Response.StatusCode)
} else {
log.Println(err)
}
}
Fixes #1047
This improves the error handling of a HEAD request response. It avoids trying to parse the body entirely. To handle the error, you can still check for a
*gitlab.ErrorResponse
: