Skip to content

Commit

Permalink
Merge pull request #10 from pmezard/remove-panics
Browse files Browse the repository at this point in the history
subframe: turn panics into errors
  • Loading branch information
mewmew committed Sep 17, 2015
2 parents a26b325 + 91b22b5 commit b115786
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions frame/subframe.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (subframe *Subframe) parseHeader(br *bits.Reader) error {
if err != nil {
return unexpected(err)
}
panic("Never seen a FLAC file contain wasted-bits-per-sample before. Not really a reason to panic, but I want to dissect one of those files. Please send it to me :)")
return fmt.Errorf("Never seen a FLAC file contain wasted-bits-per-sample before. I want to dissect one of those files. Please send it to me :)")
}

return nil
Expand Down Expand Up @@ -377,7 +377,7 @@ func (subframe *Subframe) decodeRicePart(br *bits.Reader, paramSize uint) error
if paramSize == 4 && x == 0xF || paramSize == 5 && x == 0x1F {
// 1111 or 11111: Escape code, meaning the partition is in unencoded
// binary form using n bits per sample; n follows as a 5-bit number.
panic("not yet implemented; Rice parameter escape code.")
return fmt.Errorf("not yet implemented; Rice parameter escape code.")
}
param := uint(x)

Expand Down Expand Up @@ -433,7 +433,7 @@ func (subframe *Subframe) decodeLPC(coeffs []int32, shift int32) error {
return fmt.Errorf("frame.Subframe.decodeLPC: prediction order (%d) differs from number of coefficients (%d)", subframe.Order, len(coeffs))
}
if shift < 0 {
panic("not yet implemented; negative shift.")
return fmt.Errorf("not yet implemented; negative shift.")
}
for i := subframe.Order; i < subframe.NSamples; i++ {
var sample int64
Expand Down

0 comments on commit b115786

Please sign in to comment.