Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subframe: turn panics into errors #10

Merged
merged 1 commit into from
Sep 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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