package errors import stdErrors "errors" // IsAppError reports whether err is an *AppError or wraps one anywhere in its // chain. It uses errors.As under the hood, so wrapped causes are detected too. func IsAppError(err error) bool { var target *AppError return stdErrors.As(err, &target) } // As extracts the first *AppError in err's chain, reporting whether one was // found. It mirrors errors.As but returns the typed error directly for // convenience. The returned error is the outermost AppError in the chain. func As(err error) (*AppError, bool) { var target *AppError ok := stdErrors.As(err, &target) return target, ok }