tree-wide: panic when json marshalling fails

According to the new guidelines in docs/errors.md.

Note that this does not include code that marshals to a writer that
might fail (when a connection drops, for example).
This commit is contained in:
Lars Karlitski 2020-03-25 09:29:10 +01:00
parent ad1a12f7aa
commit ee752b0ab8
4 changed files with 6 additions and 7 deletions

View file

@ -102,7 +102,7 @@ func (c *ComposerClient) AddJob() (*jobqueue.Job, error) {
var b bytes.Buffer
err := json.NewEncoder(&b).Encode(request{})
if err != nil {
return nil, err
panic(err)
}
response, err := c.client.Post(c.createURL("/job-queue/v1/jobs"), "application/json", &b)
if err != nil {
@ -129,7 +129,7 @@ func (c *ComposerClient) UpdateJob(job *jobqueue.Job, status common.ImageBuildSt
var b bytes.Buffer
err := json.NewEncoder(&b).Encode(&jobqueue.JobStatus{status, result})
if err != nil {
return err
panic(err)
}
urlPath := fmt.Sprintf("/job-queue/v1/jobs/%s/builds/%d", job.ID.String(), job.ImageBuildID)
url := c.createURL(urlPath)