From 49415d88cdd0eed102627369bfdf9de78d0e8bed Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 27 Jan 2023 01:24:02 -0700 Subject: tree-wide: Audit panic error messages These shouldn't happen, but if they do, then let's make it easier to debug. --- encode_string.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'encode_string.go') diff --git a/encode_string.go b/encode_string.go index 328b07a..208aef4 100644 --- a/encode_string.go +++ b/encode_string.go @@ -5,6 +5,7 @@ package lowmemjson import ( + "fmt" "io" "unicode/utf8" @@ -40,7 +41,7 @@ func writeStringShortEscape(w io.Writer, c rune) (int, error) { case '\t': b = 't' default: - panic("should not happen") + panic(fmt.Errorf("should not happen: writeStringShortEscape called with invalid rune: %q", c)) } buf := [2]byte{'\\', b} return w.Write(buf[:]) -- cgit v1.2.3-2-g168b