all: return less-specific, but more informative wire unmarshal errors

When proto.Unmarshal fails, it is almost always due to being passed
input which is not a wire-format message. (A text-format message, a
message with framing left intact, and so forth.) An error like
"variable length integer overflow" can be confusing in this case, since
it implies the problem is the varint rather than the input being
entirely wrong.

Replace all Unmarshal parse errors with "cannot parse invalid
wire-format data".

Change-Id: Id97253bd39ac604e569df71778194f37b3c86c28
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/244297
Reviewed-by: Joe Tsai <joetsai@google.com>
diff --git a/internal/cmd/generate-types/impl.go b/internal/cmd/generate-types/impl.go
index 6068671..96996f2 100644
--- a/internal/cmd/generate-types/impl.go
+++ b/internal/cmd/generate-types/impl.go
@@ -114,7 +114,7 @@
 	}
 	{{template "Consume" .}}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.{{.GoType.PointerMethod}}() = {{.ToGoType}}
 	out.n = n
@@ -147,7 +147,7 @@
 	}
 	{{template "Consume" .}}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	if !utf8.Valid{{if eq .Name "String"}}String{{end}}(v) {
 		return out, errInvalidUTF8{}
@@ -196,7 +196,7 @@
 	}
 	{{template "Consume" .}}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.{{.GoType.PointerMethod}}() = {{.ToGoTypeNoZero}}
 	out.n = n
@@ -235,7 +235,7 @@
 	}
 	{{template "Consume" .}}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	if !utf8.Valid{{if eq .Name "String"}}String{{end}}(v) {
 		return out, errInvalidUTF8{}
@@ -280,7 +280,7 @@
 	}
 	{{template "Consume" .}}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.{{.GoType.PointerMethod}}Ptr()
 	if *vp == nil {
@@ -319,7 +319,7 @@
 	}
 	{{template "Consume" .}}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	if !utf8.Valid{{if eq .Name "String"}}String{{end}}(v) {
 		return out, errInvalidUTF8{}
@@ -372,12 +372,12 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			{{template "Consume" .}}
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, {{.ToGoType}})
 			b = b[n:]
@@ -392,7 +392,7 @@
 	}
 	{{template "Consume" .}}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, {{.ToGoType}})
 	out.n = n
@@ -428,7 +428,7 @@
 	}
 	{{template "Consume" .}}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	if !utf8.Valid{{if eq .Name "String"}}String{{end}}(v) {
 		return out, errInvalidUTF8{}
@@ -516,7 +516,7 @@
 	}
 	{{template "Consume" .}}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return {{.ToValue}}, out, nil
@@ -551,7 +551,7 @@
 	}
 	{{template "Consume" .}}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	if !utf8.ValidString(v) {
 		return protoreflect.Value{}, out, errInvalidUTF8{}
@@ -600,12 +600,12 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			{{template "Consume" .}}
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append({{.ToValue}})
 			b = b[n:]
@@ -619,7 +619,7 @@
 	}
 	{{template "Consume" .}}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append({{.ToValue}})
 	out.n = n
diff --git a/internal/cmd/generate-types/proto.go b/internal/cmd/generate-types/proto.go
index ded7720..e91cf8d 100644
--- a/internal/cmd/generate-types/proto.go
+++ b/internal/cmd/generate-types/proto.go
@@ -290,7 +290,7 @@
 		v, n := protowire.Consume{{.WireType}}(b)
 		{{- end}}
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		{{if (eq .Name "String") -}}
 		if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
@@ -312,12 +312,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.Consume{{.WireType}}(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append({{.ToValue}})
@@ -334,7 +334,7 @@
 		v, n := protowire.Consume{{.WireType}}(b)
 		{{- end}}
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		{{if (eq .Name "String") -}}
 		if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
diff --git a/internal/impl/codec_field.go b/internal/impl/codec_field.go
index c00744d..35d4002 100644
--- a/internal/impl/codec_field.go
+++ b/internal/impl/codec_field.go
@@ -242,7 +242,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	if p.Elem().IsNil() {
 		p.SetPointer(pointerOfValue(reflect.New(f.mi.GoReflectType.Elem())))
@@ -276,7 +276,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
 		Buf:     v,
@@ -420,7 +420,7 @@
 	}
 	b, n := protowire.ConsumeGroup(num, b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
 		Buf:     b,
@@ -494,7 +494,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	m := reflect.New(f.mi.GoReflectType.Elem()).Interface()
 	mp := pointerOfIface(m)
@@ -550,7 +550,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	mp := reflect.New(goType.Elem())
 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
@@ -613,7 +613,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return pref.Value{}, out, protowire.ParseError(n)
+		return pref.Value{}, out, errDecode
 	}
 	m := list.NewElement()
 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
@@ -681,7 +681,7 @@
 	}
 	b, n := protowire.ConsumeGroup(num, b)
 	if n < 0 {
-		return pref.Value{}, out, protowire.ParseError(n)
+		return pref.Value{}, out, errDecode
 	}
 	m := list.NewElement()
 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
@@ -767,7 +767,7 @@
 	}
 	b, n := protowire.ConsumeGroup(num, b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	mp := reflect.New(goType.Elem())
 	o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
diff --git a/internal/impl/codec_gen.go b/internal/impl/codec_gen.go
index ff198d0..98aaf2d 100644
--- a/internal/impl/codec_gen.go
+++ b/internal/impl/codec_gen.go
@@ -45,7 +45,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Bool() = protowire.DecodeBool(v)
 	out.n = n
@@ -121,7 +121,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.BoolPtr()
 	if *vp == nil {
@@ -165,7 +165,7 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -180,7 +180,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, protowire.DecodeBool(v))
 			b = b[n:]
@@ -204,7 +204,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, protowire.DecodeBool(v))
 	out.n = n
@@ -285,7 +285,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfBool(protowire.DecodeBool(v)), out, nil
@@ -325,7 +325,7 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -340,7 +340,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
 			b = b[n:]
@@ -363,7 +363,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
 	out.n = n
@@ -449,7 +449,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)), out, nil
@@ -489,7 +489,7 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -504,7 +504,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
 			b = b[n:]
@@ -527,7 +527,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
 	out.n = n
@@ -615,7 +615,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Int32() = int32(v)
 	out.n = n
@@ -691,7 +691,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Int32Ptr()
 	if *vp == nil {
@@ -735,7 +735,7 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -750,7 +750,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, int32(v))
 			b = b[n:]
@@ -774,7 +774,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, int32(v))
 	out.n = n
@@ -855,7 +855,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfInt32(int32(v)), out, nil
@@ -895,7 +895,7 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -910,7 +910,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfInt32(int32(v)))
 			b = b[n:]
@@ -933,7 +933,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfInt32(int32(v)))
 	out.n = n
@@ -1021,7 +1021,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Int32() = int32(protowire.DecodeZigZag(v & math.MaxUint32))
 	out.n = n
@@ -1097,7 +1097,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Int32Ptr()
 	if *vp == nil {
@@ -1141,7 +1141,7 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -1156,7 +1156,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, int32(protowire.DecodeZigZag(v&math.MaxUint32)))
 			b = b[n:]
@@ -1180,7 +1180,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, int32(protowire.DecodeZigZag(v&math.MaxUint32)))
 	out.n = n
@@ -1261,7 +1261,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))), out, nil
@@ -1301,7 +1301,7 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -1316,7 +1316,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
 			b = b[n:]
@@ -1339,7 +1339,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
 	out.n = n
@@ -1427,7 +1427,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Uint32() = uint32(v)
 	out.n = n
@@ -1503,7 +1503,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Uint32Ptr()
 	if *vp == nil {
@@ -1547,7 +1547,7 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -1562,7 +1562,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, uint32(v))
 			b = b[n:]
@@ -1586,7 +1586,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, uint32(v))
 	out.n = n
@@ -1667,7 +1667,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfUint32(uint32(v)), out, nil
@@ -1707,7 +1707,7 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -1722,7 +1722,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfUint32(uint32(v)))
 			b = b[n:]
@@ -1745,7 +1745,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfUint32(uint32(v)))
 	out.n = n
@@ -1833,7 +1833,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Int64() = int64(v)
 	out.n = n
@@ -1909,7 +1909,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Int64Ptr()
 	if *vp == nil {
@@ -1953,7 +1953,7 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -1968,7 +1968,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, int64(v))
 			b = b[n:]
@@ -1992,7 +1992,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, int64(v))
 	out.n = n
@@ -2073,7 +2073,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfInt64(int64(v)), out, nil
@@ -2113,7 +2113,7 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -2128,7 +2128,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfInt64(int64(v)))
 			b = b[n:]
@@ -2151,7 +2151,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfInt64(int64(v)))
 	out.n = n
@@ -2239,7 +2239,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Int64() = protowire.DecodeZigZag(v)
 	out.n = n
@@ -2315,7 +2315,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Int64Ptr()
 	if *vp == nil {
@@ -2359,7 +2359,7 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -2374,7 +2374,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, protowire.DecodeZigZag(v))
 			b = b[n:]
@@ -2398,7 +2398,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, protowire.DecodeZigZag(v))
 	out.n = n
@@ -2479,7 +2479,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)), out, nil
@@ -2519,7 +2519,7 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -2534,7 +2534,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
 			b = b[n:]
@@ -2557,7 +2557,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
 	out.n = n
@@ -2645,7 +2645,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Uint64() = v
 	out.n = n
@@ -2721,7 +2721,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Uint64Ptr()
 	if *vp == nil {
@@ -2765,7 +2765,7 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -2780,7 +2780,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, v)
 			b = b[n:]
@@ -2804,7 +2804,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, v)
 	out.n = n
@@ -2885,7 +2885,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfUint64(v), out, nil
@@ -2925,7 +2925,7 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			var v uint64
@@ -2940,7 +2940,7 @@
 				v, n = protowire.ConsumeVarint(b)
 			}
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfUint64(v))
 			b = b[n:]
@@ -2963,7 +2963,7 @@
 		v, n = protowire.ConsumeVarint(b)
 	}
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfUint64(v))
 	out.n = n
@@ -3041,7 +3041,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Int32() = int32(v)
 	out.n = n
@@ -3106,7 +3106,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Int32Ptr()
 	if *vp == nil {
@@ -3148,12 +3148,12 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed32(b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, int32(v))
 			b = b[n:]
@@ -3167,7 +3167,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, int32(v))
 	out.n = n
@@ -3232,7 +3232,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfInt32(int32(v)), out, nil
@@ -3269,12 +3269,12 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed32(b)
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfInt32(int32(v)))
 			b = b[n:]
@@ -3287,7 +3287,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfInt32(int32(v)))
 	out.n = n
@@ -3357,7 +3357,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Uint32() = v
 	out.n = n
@@ -3422,7 +3422,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Uint32Ptr()
 	if *vp == nil {
@@ -3464,12 +3464,12 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed32(b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, v)
 			b = b[n:]
@@ -3483,7 +3483,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, v)
 	out.n = n
@@ -3548,7 +3548,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfUint32(uint32(v)), out, nil
@@ -3585,12 +3585,12 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed32(b)
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfUint32(uint32(v)))
 			b = b[n:]
@@ -3603,7 +3603,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfUint32(uint32(v)))
 	out.n = n
@@ -3673,7 +3673,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Float32() = math.Float32frombits(v)
 	out.n = n
@@ -3738,7 +3738,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Float32Ptr()
 	if *vp == nil {
@@ -3780,12 +3780,12 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed32(b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, math.Float32frombits(v))
 			b = b[n:]
@@ -3799,7 +3799,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, math.Float32frombits(v))
 	out.n = n
@@ -3864,7 +3864,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))), out, nil
@@ -3901,12 +3901,12 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed32(b)
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
 			b = b[n:]
@@ -3919,7 +3919,7 @@
 	}
 	v, n := protowire.ConsumeFixed32(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
 	out.n = n
@@ -3989,7 +3989,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Int64() = int64(v)
 	out.n = n
@@ -4054,7 +4054,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Int64Ptr()
 	if *vp == nil {
@@ -4096,12 +4096,12 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed64(b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, int64(v))
 			b = b[n:]
@@ -4115,7 +4115,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, int64(v))
 	out.n = n
@@ -4180,7 +4180,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfInt64(int64(v)), out, nil
@@ -4217,12 +4217,12 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed64(b)
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfInt64(int64(v)))
 			b = b[n:]
@@ -4235,7 +4235,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfInt64(int64(v)))
 	out.n = n
@@ -4305,7 +4305,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Uint64() = v
 	out.n = n
@@ -4370,7 +4370,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Uint64Ptr()
 	if *vp == nil {
@@ -4412,12 +4412,12 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed64(b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, v)
 			b = b[n:]
@@ -4431,7 +4431,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, v)
 	out.n = n
@@ -4496,7 +4496,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfUint64(v), out, nil
@@ -4533,12 +4533,12 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed64(b)
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfUint64(v))
 			b = b[n:]
@@ -4551,7 +4551,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfUint64(v))
 	out.n = n
@@ -4621,7 +4621,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Float64() = math.Float64frombits(v)
 	out.n = n
@@ -4686,7 +4686,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.Float64Ptr()
 	if *vp == nil {
@@ -4728,12 +4728,12 @@
 		s := *sp
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed64(b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			s = append(s, math.Float64frombits(v))
 			b = b[n:]
@@ -4747,7 +4747,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, math.Float64frombits(v))
 	out.n = n
@@ -4812,7 +4812,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfFloat64(math.Float64frombits(v)), out, nil
@@ -4849,12 +4849,12 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return protoreflect.Value{}, out, protowire.ParseError(n)
+			return protoreflect.Value{}, out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeFixed64(b)
 			if n < 0 {
-				return protoreflect.Value{}, out, protowire.ParseError(n)
+				return protoreflect.Value{}, out, errDecode
 			}
 			list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
 			b = b[n:]
@@ -4867,7 +4867,7 @@
 	}
 	v, n := protowire.ConsumeFixed64(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
 	out.n = n
@@ -4937,7 +4937,7 @@
 	}
 	v, n := protowire.ConsumeString(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.String() = v
 	out.n = n
@@ -4969,7 +4969,7 @@
 	}
 	v, n := protowire.ConsumeString(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	if !utf8.ValidString(v) {
 		return out, errInvalidUTF8{}
@@ -5060,7 +5060,7 @@
 	}
 	v, n := protowire.ConsumeString(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	vp := p.StringPtr()
 	if *vp == nil {
@@ -5097,7 +5097,7 @@
 	}
 	v, n := protowire.ConsumeString(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	if !utf8.ValidString(v) {
 		return out, errInvalidUTF8{}
@@ -5145,7 +5145,7 @@
 	}
 	v, n := protowire.ConsumeString(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, v)
 	out.n = n
@@ -5180,7 +5180,7 @@
 	}
 	v, n := protowire.ConsumeString(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	if !utf8.ValidString(v) {
 		return out, errInvalidUTF8{}
@@ -5216,7 +5216,7 @@
 	}
 	v, n := protowire.ConsumeString(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfString(string(v)), out, nil
@@ -5246,7 +5246,7 @@
 	}
 	v, n := protowire.ConsumeString(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	if !utf8.ValidString(v) {
 		return protoreflect.Value{}, out, errInvalidUTF8{}
@@ -5291,7 +5291,7 @@
 	}
 	v, n := protowire.ConsumeString(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfString(string(v)))
 	out.n = n
@@ -5326,7 +5326,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Bytes() = append(emptyBuf[:], v...)
 	out.n = n
@@ -5358,7 +5358,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	if !utf8.Valid(v) {
 		return out, errInvalidUTF8{}
@@ -5405,7 +5405,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*p.Bytes() = append(([]byte)(nil), v...)
 	out.n = n
@@ -5441,7 +5441,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	if !utf8.Valid(v) {
 		return out, errInvalidUTF8{}
@@ -5485,7 +5485,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	*sp = append(*sp, append(emptyBuf[:], v...))
 	out.n = n
@@ -5520,7 +5520,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	if !utf8.Valid(v) {
 		return out, errInvalidUTF8{}
@@ -5556,7 +5556,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	out.n = n
 	return protoreflect.ValueOfBytes(append(emptyBuf[:], v...)), out, nil
@@ -5598,7 +5598,7 @@
 	}
 	v, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return protoreflect.Value{}, out, protowire.ParseError(n)
+		return protoreflect.Value{}, out, errDecode
 	}
 	list.Append(protoreflect.ValueOfBytes(append(emptyBuf[:], v...)))
 	out.n = n
diff --git a/internal/impl/codec_map.go b/internal/impl/codec_map.go
index 44885a7..c1245fe 100644
--- a/internal/impl/codec_map.go
+++ b/internal/impl/codec_map.go
@@ -5,7 +5,6 @@
 package impl
 
 import (
-	"errors"
 	"reflect"
 	"sort"
 
@@ -118,7 +117,7 @@
 	}
 	b, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	var (
 		key = mapi.keyZero
@@ -127,10 +126,10 @@
 	for len(b) > 0 {
 		num, wtyp, n := protowire.ConsumeTag(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		if num > protowire.MaxValidNumber {
-			return out, errors.New("invalid field number")
+			return out, errDecode
 		}
 		b = b[n:]
 		err := errUnknown
@@ -157,7 +156,7 @@
 		if err == errUnknown {
 			n = protowire.ConsumeFieldValue(num, wtyp, b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 		} else if err != nil {
 			return out, err
@@ -175,7 +174,7 @@
 	}
 	b, n := protowire.ConsumeBytes(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	var (
 		key = mapi.keyZero
@@ -184,10 +183,10 @@
 	for len(b) > 0 {
 		num, wtyp, n := protowire.ConsumeTag(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		if num > protowire.MaxValidNumber {
-			return out, errors.New("invalid field number")
+			return out, errDecode
 		}
 		b = b[n:]
 		err := errUnknown
@@ -208,7 +207,7 @@
 			var v []byte
 			v, n = protowire.ConsumeBytes(b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			var o unmarshalOutput
 			o, err = f.mi.unmarshalPointer(v, pointerOfValue(val), 0, opts)
@@ -221,7 +220,7 @@
 		if err == errUnknown {
 			n = protowire.ConsumeFieldValue(num, wtyp, b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 		} else if err != nil {
 			return out, err
diff --git a/internal/impl/codec_reflect.go b/internal/impl/codec_reflect.go
index 86f7dc3..90705e3 100644
--- a/internal/impl/codec_reflect.go
+++ b/internal/impl/codec_reflect.go
@@ -30,7 +30,7 @@
 	}
 	v, n := protowire.ConsumeVarint(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	p.v.Elem().SetInt(int64(v))
 	out.n = n
@@ -130,12 +130,12 @@
 	if wtyp == protowire.BytesType {
 		b, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return out, protowire.ParseError(n)
+			return out, errDecode
 		}
 		for len(b) > 0 {
 			v, n := protowire.ConsumeVarint(b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			rv := reflect.New(s.Type().Elem()).Elem()
 			rv.SetInt(int64(v))
@@ -150,7 +150,7 @@
 	}
 	v, n := protowire.ConsumeVarint(b)
 	if n < 0 {
-		return out, protowire.ParseError(n)
+		return out, errDecode
 	}
 	rv := reflect.New(s.Type().Elem()).Elem()
 	rv.SetInt(int64(v))
diff --git a/internal/impl/decode.go b/internal/impl/decode.go
index 85ba1d3..2dcbdec 100644
--- a/internal/impl/decode.go
+++ b/internal/impl/decode.go
@@ -17,6 +17,8 @@
 	piface "google.golang.org/protobuf/runtime/protoiface"
 )
 
+var errDecode = errors.New("cannot parse invalid wire-format data")
+
 type unmarshalOptions struct {
 	flags    protoiface.UnmarshalInputFlags
 	resolver interface {
@@ -100,13 +102,13 @@
 			var n int
 			tag, n = protowire.ConsumeVarint(b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			b = b[n:]
 		}
 		var num protowire.Number
 		if n := tag >> 3; n < uint64(protowire.MinValidNumber) || n > uint64(protowire.MaxValidNumber) {
-			return out, errors.New("invalid field number")
+			return out, errDecode
 		} else {
 			num = protowire.Number(n)
 		}
@@ -114,7 +116,7 @@
 
 		if wtyp == protowire.EndGroupType {
 			if num != groupTag {
-				return out, errors.New("mismatching end group marker")
+				return out, errDecode
 			}
 			groupTag = 0
 			break
@@ -170,7 +172,7 @@
 			}
 			n = protowire.ConsumeFieldValue(num, wtyp, b)
 			if n < 0 {
-				return out, protowire.ParseError(n)
+				return out, errDecode
 			}
 			if !opts.DiscardUnknown() && mi.unknownOffset.IsValid() {
 				u := p.Apply(mi.unknownOffset).Bytes()
@@ -181,7 +183,7 @@
 		b = b[n:]
 	}
 	if groupTag != 0 {
-		return out, errors.New("missing end group marker")
+		return out, errDecode
 	}
 	if mi.numRequiredFields > 0 && bits.OnesCount64(requiredMask) != int(mi.numRequiredFields) {
 		initialized = false
@@ -221,7 +223,7 @@
 					return out, nil
 				}
 			case ValidationInvalid:
-				return out, errors.New("invalid wire format")
+				return out, errDecode
 			case ValidationUnknown:
 			}
 		}
diff --git a/proto/decode.go b/proto/decode.go
index 42fc519..a0efaa0 100644
--- a/proto/decode.go
+++ b/proto/decode.go
@@ -116,10 +116,10 @@
 		// Parse the tag (field number and wire type).
 		num, wtyp, tagLen := protowire.ConsumeTag(b)
 		if tagLen < 0 {
-			return protowire.ParseError(tagLen)
+			return errDecode
 		}
 		if num > protowire.MaxValidNumber {
-			return errors.New("invalid field number")
+			return errDecode
 		}
 
 		// Find the field descriptor for this field number.
@@ -159,7 +159,7 @@
 			}
 			valLen = protowire.ConsumeFieldValue(num, wtyp, b[tagLen:])
 			if valLen < 0 {
-				return protowire.ParseError(valLen)
+				return errDecode
 			}
 			if !o.DiscardUnknown {
 				m.SetUnknown(append(m.GetUnknown(), b[:tagLen+valLen]...))
@@ -194,7 +194,7 @@
 	}
 	b, n = protowire.ConsumeBytes(b)
 	if n < 0 {
-		return 0, protowire.ParseError(n)
+		return 0, errDecode
 	}
 	var (
 		keyField = fd.MapKey()
@@ -213,10 +213,10 @@
 	for len(b) > 0 {
 		num, wtyp, n := protowire.ConsumeTag(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		if num > protowire.MaxValidNumber {
-			return 0, errors.New("invalid field number")
+			return 0, errDecode
 		}
 		b = b[n:]
 		err = errUnknown
@@ -246,7 +246,7 @@
 		if err == errUnknown {
 			n = protowire.ConsumeFieldValue(num, wtyp, b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 		} else if err != nil {
 			return 0, err
@@ -272,3 +272,5 @@
 // to the unknown field set of a message. It is never returned from an exported
 // function.
 var errUnknown = errors.New("BUG: internal error (unknown)")
+
+var errDecode = errors.New("cannot parse invalid wire-format data")
diff --git a/proto/decode_gen.go b/proto/decode_gen.go
index d6dc904..301eeb2 100644
--- a/proto/decode_gen.go
+++ b/proto/decode_gen.go
@@ -27,7 +27,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfBool(protowire.DecodeBool(v)), n, nil
 	case protoreflect.EnumKind:
@@ -36,7 +36,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)), n, nil
 	case protoreflect.Int32Kind:
@@ -45,7 +45,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfInt32(int32(v)), n, nil
 	case protoreflect.Sint32Kind:
@@ -54,7 +54,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))), n, nil
 	case protoreflect.Uint32Kind:
@@ -63,7 +63,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfUint32(uint32(v)), n, nil
 	case protoreflect.Int64Kind:
@@ -72,7 +72,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfInt64(int64(v)), n, nil
 	case protoreflect.Sint64Kind:
@@ -81,7 +81,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)), n, nil
 	case protoreflect.Uint64Kind:
@@ -90,7 +90,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfUint64(v), n, nil
 	case protoreflect.Sfixed32Kind:
@@ -99,7 +99,7 @@
 		}
 		v, n := protowire.ConsumeFixed32(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfInt32(int32(v)), n, nil
 	case protoreflect.Fixed32Kind:
@@ -108,7 +108,7 @@
 		}
 		v, n := protowire.ConsumeFixed32(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfUint32(uint32(v)), n, nil
 	case protoreflect.FloatKind:
@@ -117,7 +117,7 @@
 		}
 		v, n := protowire.ConsumeFixed32(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))), n, nil
 	case protoreflect.Sfixed64Kind:
@@ -126,7 +126,7 @@
 		}
 		v, n := protowire.ConsumeFixed64(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfInt64(int64(v)), n, nil
 	case protoreflect.Fixed64Kind:
@@ -135,7 +135,7 @@
 		}
 		v, n := protowire.ConsumeFixed64(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfUint64(v), n, nil
 	case protoreflect.DoubleKind:
@@ -144,7 +144,7 @@
 		}
 		v, n := protowire.ConsumeFixed64(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfFloat64(math.Float64frombits(v)), n, nil
 	case protoreflect.StringKind:
@@ -153,7 +153,7 @@
 		}
 		v, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
 			return protoreflect.Value{}, 0, errors.InvalidUTF8(string(fd.FullName()))
@@ -165,7 +165,7 @@
 		}
 		v, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfBytes(append(emptyBuf[:], v...)), n, nil
 	case protoreflect.MessageKind:
@@ -174,7 +174,7 @@
 		}
 		v, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfBytes(v), n, nil
 	case protoreflect.GroupKind:
@@ -183,7 +183,7 @@
 		}
 		v, n := protowire.ConsumeGroup(fd.Number(), b)
 		if n < 0 {
-			return val, 0, protowire.ParseError(n)
+			return val, 0, errDecode
 		}
 		return protoreflect.ValueOfBytes(v), n, nil
 	default:
@@ -197,12 +197,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeVarint(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
@@ -214,7 +214,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfBool(protowire.DecodeBool(v)))
 		return n, nil
@@ -222,12 +222,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeVarint(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
@@ -239,7 +239,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfEnum(protoreflect.EnumNumber(v)))
 		return n, nil
@@ -247,12 +247,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeVarint(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfInt32(int32(v)))
@@ -264,7 +264,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfInt32(int32(v)))
 		return n, nil
@@ -272,12 +272,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeVarint(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
@@ -289,7 +289,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfInt32(int32(protowire.DecodeZigZag(v & math.MaxUint32))))
 		return n, nil
@@ -297,12 +297,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeVarint(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfUint32(uint32(v)))
@@ -314,7 +314,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfUint32(uint32(v)))
 		return n, nil
@@ -322,12 +322,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeVarint(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfInt64(int64(v)))
@@ -339,7 +339,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfInt64(int64(v)))
 		return n, nil
@@ -347,12 +347,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeVarint(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
@@ -364,7 +364,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfInt64(protowire.DecodeZigZag(v)))
 		return n, nil
@@ -372,12 +372,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeVarint(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfUint64(v))
@@ -389,7 +389,7 @@
 		}
 		v, n := protowire.ConsumeVarint(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfUint64(v))
 		return n, nil
@@ -397,12 +397,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeFixed32(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfInt32(int32(v)))
@@ -414,7 +414,7 @@
 		}
 		v, n := protowire.ConsumeFixed32(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfInt32(int32(v)))
 		return n, nil
@@ -422,12 +422,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeFixed32(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfUint32(uint32(v)))
@@ -439,7 +439,7 @@
 		}
 		v, n := protowire.ConsumeFixed32(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfUint32(uint32(v)))
 		return n, nil
@@ -447,12 +447,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeFixed32(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
@@ -464,7 +464,7 @@
 		}
 		v, n := protowire.ConsumeFixed32(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfFloat32(math.Float32frombits(uint32(v))))
 		return n, nil
@@ -472,12 +472,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeFixed64(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfInt64(int64(v)))
@@ -489,7 +489,7 @@
 		}
 		v, n := protowire.ConsumeFixed64(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfInt64(int64(v)))
 		return n, nil
@@ -497,12 +497,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeFixed64(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfUint64(v))
@@ -514,7 +514,7 @@
 		}
 		v, n := protowire.ConsumeFixed64(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfUint64(v))
 		return n, nil
@@ -522,12 +522,12 @@
 		if wtyp == protowire.BytesType {
 			buf, n := protowire.ConsumeBytes(b)
 			if n < 0 {
-				return 0, protowire.ParseError(n)
+				return 0, errDecode
 			}
 			for len(buf) > 0 {
 				v, n := protowire.ConsumeFixed64(buf)
 				if n < 0 {
-					return 0, protowire.ParseError(n)
+					return 0, errDecode
 				}
 				buf = buf[n:]
 				list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
@@ -539,7 +539,7 @@
 		}
 		v, n := protowire.ConsumeFixed64(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfFloat64(math.Float64frombits(v)))
 		return n, nil
@@ -549,7 +549,7 @@
 		}
 		v, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		if strs.EnforceUTF8(fd) && !utf8.Valid(v) {
 			return 0, errors.InvalidUTF8(string(fd.FullName()))
@@ -562,7 +562,7 @@
 		}
 		v, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		list.Append(protoreflect.ValueOfBytes(append(emptyBuf[:], v...)))
 		return n, nil
@@ -572,7 +572,7 @@
 		}
 		v, n := protowire.ConsumeBytes(b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		m := list.NewElement()
 		if err := o.unmarshalMessage(v, m.Message()); err != nil {
@@ -586,7 +586,7 @@
 		}
 		v, n := protowire.ConsumeGroup(fd.Number(), b)
 		if n < 0 {
-			return 0, protowire.ParseError(n)
+			return 0, errDecode
 		}
 		m := list.NewElement()
 		if err := o.unmarshalMessage(v, m.Message()); err != nil {
diff --git a/proto/testmessages_test.go b/proto/testmessages_test.go
index 9979d77..a021b3f 100644
--- a/proto/testmessages_test.go
+++ b/proto/testmessages_test.go
@@ -818,7 +818,7 @@
 				protopack.Tag{2, protopack.VarintType}, protopack.Varint(1156),
 			}),
 			protopack.Tag{71, protopack.BytesType}, protopack.LengthPrefix(protopack.Message{
-				protopack.Tag{1, protopack.BytesType}, protopack.String(0),
+				protopack.Tag{1, protopack.BytesType}, protopack.String(""),
 				protopack.Tag{2, protopack.BytesType}, protopack.LengthPrefix(protopack.Message{}),
 				protopack.Tag{1, protopack.BytesType}, protopack.String("71.1.key"),
 				protopack.Tag{2, protopack.BytesType}, protopack.LengthPrefix(protopack.Message{