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:
parent
ad1a12f7aa
commit
ee752b0ab8
4 changed files with 6 additions and 7 deletions
|
|
@ -141,7 +141,7 @@ func main() {
|
|||
}
|
||||
bytes, err = json.Marshal(rpmMDInfo)
|
||||
if err != nil {
|
||||
panic("could not marshal rpmmd struct into JSON")
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
manifest, err := imageType.Manifest(blueprint.Customizations, repos[arch.Name()], packageSpecs, buildPackageSpecs, imageType.Size(0))
|
||||
|
|
@ -151,7 +151,7 @@ func main() {
|
|||
|
||||
bytes, err = json.Marshal(manifest)
|
||||
if err != nil {
|
||||
panic("could not marshal manifest into JSON")
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
os.Stdout.Write(bytes)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -43,13 +43,13 @@ type Group struct {
|
|||
func (b *Blueprint) DeepCopy() (Blueprint, error) {
|
||||
bpJSON, err := json.Marshal(b)
|
||||
if err != nil {
|
||||
return Blueprint{}, err
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var bp Blueprint
|
||||
err = json.Unmarshal(bpJSON, &bp)
|
||||
if err != nil {
|
||||
return Blueprint{}, err
|
||||
panic(err)
|
||||
}
|
||||
return bp, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,7 +287,6 @@ func (s *Store) change(f func() error) error {
|
|||
if s.stateChannel != nil {
|
||||
serialized, err := json.Marshal(s)
|
||||
if err != nil {
|
||||
// we ought to know all types that go into the store
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue