makiuchi-d / gozxing

Port of ZXing (https://github.com/zxing/zxing) core to pure Go.
Other
549 stars 66 forks source link

How to handle error NotFoundException: startSize = 0 #65

Closed JamesKrub closed 3 weeks ago

JamesKrub commented 7 months ago

please kindly recommend me to check specific error without using like this in Golang

err.Error() == "NotFoundException: startSize = 0"

makiuchi-d commented 7 months ago

Using errors.As:

var t gozxing.NotFoundException
if errors.As(err, t) {
    fmt.Println("Not found exception")
}

Or, using type assertion:

_, ok := err.(gozxing.NotFoundException)
if ok {
    fmt.Println("Not found exception")
}