diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2023-01-27 01:24:02 -0700 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2023-02-10 21:54:37 -0700 |
commit | 49415d88cdd0eed102627369bfdf9de78d0e8bed (patch) | |
tree | 0ec8a2d602eb234a37c0d39906e4c645e6b8bac8 /internal | |
parent | cf8f8527e968c448995bdcaaad9c4351d3a2ab3f (diff) |
tree-wide: Audit panic error messages
These shouldn't happen, but if they do, then let's make it easier to
debug.
Diffstat (limited to 'internal')
-rw-r--r-- | internal/jsonparse/parse.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/jsonparse/parse.go b/internal/jsonparse/parse.go index 7d97be0..73584d9 100644 --- a/internal/jsonparse/parse.go +++ b/internal/jsonparse/parse.go @@ -401,7 +401,7 @@ func (par *Parser) PushReadBarrier() { // Sanity checking. par.init() if len(par.stack) == 0 { - panic(errors.New("illegal PushReadBarrier call: empty stack")) + panic(errors.New("should not happen: illegal PushReadBarrier call: empty stack")) } curState := par.stack[len(par.stack)-1] switch curState { @@ -415,7 +415,7 @@ func (par *Parser) PushReadBarrier() { RuneTypeNullN: // OK default: - panic(fmt.Errorf("illegal PushReadBarrier call: %q", curState)) + panic(fmt.Errorf("should not happen: illegal PushReadBarrier call: %q", curState)) } // Actually push. par.barriers = append(par.barriers, barrier{ @@ -441,7 +441,7 @@ func (par *Parser) PushReadBarrier() { func (par *Parser) PushWriteBarrier() { par.init() if len(par.stack) == 0 { - panic(errors.New("illegal PushWriteBarrier call: empty stack")) + panic(errors.New("should not happen: illegal PushWriteBarrier call: empty stack")) } switch par.stack[len(par.stack)-1] { case runeTypeAny: @@ -459,14 +459,14 @@ func (par *Parser) PushWriteBarrier() { }) par.stack = []RuneType{runeTypeAny} default: - panic(fmt.Errorf("illegal PushWriteBarrier call: %q", par.stack[len(par.stack)-1])) + panic(fmt.Errorf("should not happen: illegal PushWriteBarrier call: %q", par.stack[len(par.stack)-1])) } } // PopBarrier reverses a call to PushReadBarrier or PushWriteBarrier. func (par *Parser) PopBarrier() { if len(par.barriers) == 0 { - panic(errors.New("illegal PopBarrier call: empty barrier stack")) + panic(errors.New("should not happen: illegal PopBarrier call: empty barrier stack")) } barrier := par.barriers[len(par.barriers)-1] par.barriers = par.barriers[:len(par.barriers)-1] @@ -828,7 +828,7 @@ func (par *Parser) HandleRune(c rune) (RuneType, error) { case RuneTypeNullL1: return par.expectRune(c, 'l', RuneTypeNullL2, "null", true) default: - panic(fmt.Errorf(`invalid stack: "%s"`, par.stackString())) + panic(fmt.Errorf(`should not happen: invalid stack: "%s"`, par.stackString())) } } |