Standard library / strconv

strconv.NumError

Conversion error with Func, Num and Err fields; Error returns descriptive text, Unwrap returns the underlying cause. Use errors.As to recover details without parsing messages. Expected stdout: 'true Atoi bad true\n'.

Formal Syntax & Structure

go syntaxgo
type NumError struct { Func string; Num string; Err error }

Working Example

Example Snippetgo
package main
import (  "errors"  "fmt"  "strconv")
func main() {  _, e := strconv.Atoi("bad")  var n *strconv.NumError  fmt.Println(errors.As(e, &n), n.Func, n.Num, errors.Is(n.Unwrap(), strconv.ErrSyntax))}
Go Reference