1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-07 13:31:37 +02:00

fix: improve artifactory error handling (#3546)

closes #3543

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2022-11-12 00:49:08 -03:00 committed by GitHub
parent c4fd0a0c5b
commit 778f099a9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 7 deletions

View File

@ -79,7 +79,7 @@ func checkResponse(r *h.Response) error {
if err == nil && data != nil {
err := json.Unmarshal(data, errorResponse)
if err != nil {
return err
return fmt.Errorf("unexpected error: %w: %s", err, string(data))
}
}
return errorResponse

View File

@ -461,11 +461,7 @@ func TestRunPipe_UnparsableErrorResponse(t *testing.T) {
requireHeader(t, r, "Authorization", "Basic ZGVwbG95dXNlcjpkZXBsb3l1c2VyLXNlY3JldA==")
w.WriteHeader(http.StatusUnauthorized)
fmt.Fprint(w, `...{
"errors" : [ {
...
} ]
}`)
fmt.Fprint(w, `<body><h1>error</h1></body>`)
})
ctx := context.New(config.Project{
@ -495,7 +491,7 @@ func TestRunPipe_UnparsableErrorResponse(t *testing.T) {
})
require.NoError(t, Pipe{}.Default(ctx))
require.EqualError(t, Pipe{}.Publish(ctx), `artifactory: upload failed: invalid character '.' looking for beginning of value`)
require.EqualError(t, Pipe{}.Publish(ctx), `artifactory: upload failed: unexpected error: invalid character '<' looking for beginning of value: <body><h1>error</h1></body>`)
}
func TestRunPipe_FileNotFound(t *testing.T) {