-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #195 from goccy/feature/support-utility-for-error
Support a new feature to help compare error instance
- Loading branch information
Showing
3 changed files
with
93 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package yaml | ||
|
||
import ( | ||
"github.com/goccy/go-yaml/ast" | ||
"golang.org/x/xerrors" | ||
) | ||
|
||
var ( | ||
ErrInvalidQuery = xerrors.New("invalid query") | ||
ErrInvalidPath = xerrors.New("invalid path instance") | ||
ErrInvalidPathString = xerrors.New("invalid path string") | ||
ErrNotFoundNode = xerrors.New("node not found") | ||
) | ||
|
||
// IsInvalidQueryError whether err is ErrInvalidQuery or not. | ||
func IsInvalidQueryError(err error) bool { | ||
return xerrors.Is(err, ErrInvalidQuery) | ||
} | ||
|
||
// IsInvalidPathError whether err is ErrInvalidPath or not. | ||
func IsInvalidPathError(err error) bool { | ||
return xerrors.Is(err, ErrInvalidPath) | ||
} | ||
|
||
// IsInvalidPathStringError whether err is ErrInvalidPathString or not. | ||
func IsInvalidPathStringError(err error) bool { | ||
return xerrors.Is(err, ErrInvalidPathString) | ||
} | ||
|
||
// IsNotFoundNodeError whether err is ErrNotFoundNode or not. | ||
func IsNotFoundNodeError(err error) bool { | ||
return xerrors.Is(err, ErrNotFoundNode) | ||
} | ||
|
||
// IsInvalidTokenTypeError whether err is ast.ErrInvalidTokenType or not. | ||
func IsInvalidTokenTypeError(err error) bool { | ||
return xerrors.Is(err, ast.ErrInvalidTokenType) | ||
} | ||
|
||
// IsInvalidAnchorNameError whether err is ast.ErrInvalidAnchorName or not. | ||
func IsInvalidAnchorNameError(err error) bool { | ||
return xerrors.Is(err, ast.ErrInvalidAnchorName) | ||
} | ||
|
||
// IsInvalidAliasNameError whether err is ast.ErrInvalidAliasName or not. | ||
func IsInvalidAliasNameError(err error) bool { | ||
return xerrors.Is(err, ast.ErrInvalidAliasName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters