Commit graph

10 commits

Author SHA1 Message Date
Masaaki Goshima
271213ad23
fix error (#535) 2024-11-14 16:01:08 +09:00
Masaaki Goshima
548bbc7d4e
Remove xerrors (#483)
* remove xerrors

* move error variable

* update dependencies
2024-10-28 21:24:15 +09:00
alvar
56f8b293f7
Refactor overflowError to be pretty-printable (#470)
When trying to yaml.Unmarshal a negative number into an uint, the
resulting error indicates an overflow with type information, but without
the position. For example:

> cannot unmarshal -23 into Go value of type uint64 ( overflow )

From an end user's perspective reading an error for an invalid YAML,
this is quite unintuitive. Especially compared to the error message when
trying to unmarshal a string into an uint.

> [1:4] cannot unmarshal string into Go struct field Foo.A of type uint64
>     >  1 | a: 'foo'
>               ^

This change has moved overflowError to internal.errors.overflowError,
implementing both the PrettyPrinter and Formatter. Its implementation is
uniform with those of the syntaxError and TypeError.

Thus, the error from above now looks like:

> [1:4] cannot unmarshal -23 into Go value of type uint64 ( overflow )
>     >  1 | a: -23
>               ^
2024-10-28 16:04:03 +09:00
Shuhei Kitagawa
8ad318cffc
Add lint job to CI (#477) 2024-10-28 11:31:15 +09:00
Braydon Kains
bf2da56730 internal/errors: moved typeError to errors package
The typeError previously located in decode.go now implements
PrettyPrinter, so it's been moved to internal/errors to be colocated
with the other PrettyPrinter errors.
2022-05-02 18:00:24 +00:00
Braydon Kains
dad2dedc90 yaml: typeError implements PrettyPrinter interface
When unmarshalling YAML and encountering an error in decoded that
results in a `yaml.typeError`, the error can't have the same nice
formatting because it doesn't implement the `errors.PrettyPrinter`
interface. This adds a field to the `yaml.typeError` struct that
specifies a token which is used in the implementation of the
PrettyPrinter interface. The tests were updated to instead match on
expected message substrings instead of full equality.
2022-02-09 23:06:32 +00:00
nasa9084
ed4b5a14ba add (*wrapError).Unwrap() to be usable for (x)errors.Is 2020-05-18 23:59:27 +09:00
Masaaki Goshima
2f17b05e19 Improve code coverage for inline struct 2019-12-11 00:41:05 +09:00
Daisuke Maki
20adab4162 small fixes here and there, documentation 2019-10-24 15:28:41 +09:00
Daisuke Maki
d6a5e04d34 PoC for #4 2019-10-24 11:07:40 +09:00