We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b38be35 commit 712f3dfCopy full SHA for 712f3df
src/strconv/atoi.go
@@ -31,6 +31,8 @@ func (e *NumError) Error() string {
31
return "strconv." + e.Func + ": " + "parsing " + Quote(e.Num) + ": " + e.Err.Error()
32
}
33
34
+func (e *NumError) Unwrap() error { return e.Err }
35
+
36
func syntaxError(fn, str string) *NumError {
37
return &NumError{fn, str, ErrSyntax}
38
src/strconv/atoi_test.go
@@ -592,6 +592,13 @@ func TestNumError(t *testing.T) {
592
593
594
595
+func TestNumErrorUnwrap(t *testing.T) {
596
+ err := &NumError{Err: ErrSyntax}
597
+ if !errors.Is(err, ErrSyntax) {
598
+ t.Error("errors.Is failed, wanted success")
599
+ }
600
+}
601
602
func BenchmarkParseInt(b *testing.B) {
603
b.Run("Pos", func(b *testing.B) {
604
benchmarkParseInt(b, 1)
0 commit comments