1
0
mirror of https://github.com/IBM/fp-go.git synced 2025-08-10 22:31:32 +02:00
Files
fp-go/errors/conv.go
Dr. Carsten Leue b25de3c7c3 doc: fix case
Signed-off-by: Dr. Carsten Leue <carsten.leue@de.ibm.com>
2023-07-18 15:57:54 +02:00

17 lines
298 B
Go

package errors
import (
"errors"
O "github.com/IBM/fp-go/option"
)
// As tries to extract the error of desired type from the given error
func As[A error]() func(error) O.Option[A] {
return O.FromValidation(func(err error) (A, bool) {
var a A
ok := errors.As(err, &a)
return a, ok
})
}