| 1 |
package yaml |
| 2 |
|
| 3 |
import ( |
| 4 |
"errors" |
| 5 |
"fmt" |
| 6 |
|
| 7 |
"github.com/goccy/go-yaml/ast" |
| 8 |
) |
| 9 |
|
| 10 |
var ( |
| 11 |
ErrInvalidQuery = errors.New("invalid query") |
| 12 |
ErrInvalidPath = errors.New("invalid path instance") |
| 13 |
ErrInvalidPathString = errors.New("invalid path string") |
| 14 |
ErrNotFoundNode = errors.New("node not found") |
| 15 |
ErrUnknownCommentPositionType = errors.New("unknown comment position type") |
| 16 |
ErrInvalidCommentMapValue = errors.New("invalid comment map value. it must be not nil value") |
| 17 |
ErrDecodeRequiredPointerType = errors.New("required pointer type value") |
| 18 |
) |
| 19 |
|
| 20 |
func ErrUnsupportedHeadPositionType(node ast.Node) error { |
| 21 |
return fmt.Errorf("unsupported comment head position for %s", node.Type()) |
| 22 |
} |
| 23 |
|
| 24 |
func ErrUnsupportedLinePositionType(node ast.Node) error { |
| 25 |
return fmt.Errorf("unsupported comment line position for %s", node.Type()) |
| 26 |
} |
| 27 |
|
| 28 |
func ErrUnsupportedFootPositionType(node ast.Node) error { |
| 29 |
return fmt.Errorf("unsupported comment foot position for %s", node.Type()) |
| 30 |
} |
| 31 |
|
| 32 |
// IsInvalidQueryError whether err is ErrInvalidQuery or not. |
| 33 |
func IsInvalidQueryError(err error) bool { |
| 34 |
return errors.Is(err, ErrInvalidQuery) |
| 35 |
} |
| 36 |
|
| 37 |
// IsInvalidPathError whether err is ErrInvalidPath or not. |
| 38 |
func IsInvalidPathError(err error) bool { |
| 39 |
return errors.Is(err, ErrInvalidPath) |
| 40 |
} |
| 41 |
|
| 42 |
// IsInvalidPathStringError whether err is ErrInvalidPathString or not. |
| 43 |
func IsInvalidPathStringError(err error) bool { |
| 44 |
return errors.Is(err, ErrInvalidPathString) |
| 45 |
} |
| 46 |
|
| 47 |
// IsNotFoundNodeError whether err is ErrNotFoundNode or not. |
| 48 |
func IsNotFoundNodeError(err error) bool { |
| 49 |
return errors.Is(err, ErrNotFoundNode) |
| 50 |
} |
| 51 |
|
| 52 |
// IsInvalidTokenTypeError whether err is ast.ErrInvalidTokenType or not. |
| 53 |
func IsInvalidTokenTypeError(err error) bool { |
| 54 |
return errors.Is(err, ast.ErrInvalidTokenType) |
| 55 |
} |
| 56 |
|
| 57 |
// IsInvalidAnchorNameError whether err is ast.ErrInvalidAnchorName or not. |
| 58 |
func IsInvalidAnchorNameError(err error) bool { |
| 59 |
return errors.Is(err, ast.ErrInvalidAnchorName) |
| 60 |
} |
| 61 |
|
| 62 |
// IsInvalidAliasNameError whether err is ast.ErrInvalidAliasName or not. |
| 63 |
func IsInvalidAliasNameError(err error) bool { |
| 64 |
return errors.Is(err, ast.ErrInvalidAliasName) |
| 65 |
} |