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

@ -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
}

View file

@ -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)
}