kubernetes-sigs / yaml

A better way to marshal and unmarshal YAML in Golang
Other
246 stars 75 forks source link

Richer typed errors #67

Open smlx opened 3 years ago

smlx commented 3 years ago

encoding/json has various error types that Unmarshal can return such as

type UnmarshalTypeError struct {
    Value  string       // description of JSON value - "bool", "array", "number -5"
    Type   reflect.Type // type of Go value it could not be assigned to
    Offset int64        // error occurred after reading Offset bytes
    Struct string       // name of the struct type containing the field
    Field  string       // the full path from root node to the field
}

This contains lots of useful information that could be used when debugging yaml.Unmarshal errors. From what I can tell yaml.Unmarshal currently discards the rich error type returned by json.Unmarshal.

Could this package produce better errors along the lines of those used by encoding/json?

I see #9 is very similar but I'm not sure why that was closed, so I'm creating a new issue to track/discuss this.

k8s-triage-robot commented 2 years ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

smlx commented 2 years ago

/remove-lifecycle stale

k8s-triage-robot commented 2 years ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

smlx commented 2 years ago

/remove-lifecycle stale

k8s-triage-robot commented 2 years ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

smlx commented 2 years ago

/remove-lifecycle stale /lifecycle frozen