Skip to content

Commit

Permalink
Merge pull request #162 from i110/i110/more-descriptive-error-message
Browse files Browse the repository at this point in the history
tweak error messages to be more descriptive
  • Loading branch information
goccy authored Sep 19, 2020
2 parents d2d6e68 + 4c79152 commit 81f720d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func (d *Decoder) getMapNode(node ast.Node) (ast.MapNode, error) {
if ok {
return mapNode, nil
}
return nil, xerrors.Errorf("%s node doesn't MapNode", anchor.Value.Type())
return nil, xerrors.Errorf("%s node found where MapNode is expected", anchor.Value.Type())
}
if alias, ok := node.(*ast.AliasNode); ok {
aliasName := alias.Value.GetToken().Value
Expand All @@ -288,11 +288,11 @@ func (d *Decoder) getMapNode(node ast.Node) (ast.MapNode, error) {
if ok {
return mapNode, nil
}
return nil, xerrors.Errorf("%s node doesn't MapNode", node.Type())
return nil, xerrors.Errorf("%s node found where MapNode is expected", node.Type())
}
mapNode, ok := node.(ast.MapNode)
if !ok {
return nil, xerrors.Errorf("%s node doesn't MapNode", node.Type())
return nil, xerrors.Errorf("%s node found where MapNode is expected", node.Type())
}
return mapNode, nil
}
Expand All @@ -306,7 +306,7 @@ func (d *Decoder) getArrayNode(node ast.Node) (ast.ArrayNode, error) {
if ok {
return arrayNode, nil
}
return nil, xerrors.Errorf("%s node doesn't ArrayNode", anchor.Value.Type())
return nil, xerrors.Errorf("%s node found where ArrayNode is expected", anchor.Value.Type())
}
if alias, ok := node.(*ast.AliasNode); ok {
aliasName := alias.Value.GetToken().Value
Expand All @@ -318,11 +318,11 @@ func (d *Decoder) getArrayNode(node ast.Node) (ast.ArrayNode, error) {
if ok {
return arrayNode, nil
}
return nil, xerrors.Errorf("%s node doesn't ArrayNode", node.Type())
return nil, xerrors.Errorf("%s node found where ArrayNode is expected", node.Type())
}
arrayNode, ok := node.(ast.ArrayNode)
if !ok {
return nil, xerrors.Errorf("%s node doesn't ArrayNode", node.Type())
return nil, xerrors.Errorf("%s node found where ArrayNode is expected", node.Type())
}
return arrayNode, nil
}
Expand Down

0 comments on commit 81f720d

Please sign in to comment.