clienterrors: rename WorkerClientError to clienterrors.New

The usual convention to create new object is to prefix `New*` so
this commit renames the `WorkerClientError`. Initially I thought
it would be `NewWorkerClientError()` but looking at the package
prefix it seems unneeded, i.e. `clienterrors.New()` already
provides enough context it seems and it's the only error we
construct.

We could consider renaming it to `clienterror` (singular) too
but that could be a followup.

I would also like to make `clienterror.Error` implement the
`error` interface but that should be a followup to make this
(mechanical) rename trivial to review.
This commit is contained in:
Michael Vogt 2024-05-13 17:39:01 +02:00
parent 09445a1030
commit 573b349f16
19 changed files with 188 additions and 188 deletions

View file

@ -109,7 +109,7 @@ func TestComposeStatusFromJobError(t *testing.T) {
require.Equal(t, jobId, j)
jobResult := worker.OSBuildJobResult{}
jobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, "Upload error", nil)
jobResult.JobError = clienterrors.New(clienterrors.ErrorUploadingImage, "Upload error", nil)
rawResult, err := json.Marshal(jobResult)
require.NoError(t, err)
err = api.workers.FinishJob(token, rawResult)