On Wed, Sep 2, 2020 at 10:31 AM 'simon place' via golang-nuts
<golang-nuts@googlegroups.com> wrote:
>
> my understanding is the whole wrap mechanism is to move to types, rather than 
> strings, so you can test for a 'class' of error without the hacky use of 
> string comparison.

You do that using errors.Is and errors.As that use the Unwrap method
to descend the error chain. Error() simply returns a string
representation of the error.

>
> On Wednesday, 2 September 2020 17:18:10 UTC+1, burak serdar wrote:
>>
>> On Wed, Sep 2, 2020 at 10:05 AM 'simon place' via golang-nuts
>> <golan...@googlegroups.com> wrote:
>> >
>> > the example compares the print output of a fmt.errorf wrapped error and a 
>> > custom-error type wrapped error, the custom one isn't showing the wrapped 
>> > error.,
>>
>> It will if you also print the wrapped error:
>>
>> func (e MyErr) Error() string {
>>    return "My wrapping:"+ e.error.Error()
>> }
>>
>>
>>
>> >
>> > On Wednesday, 2 September 2020 16:58:31 UTC+1, burak serdar wrote:
>> >>
>> >> On Wed, Sep 2, 2020 at 9:48 AM 'simon place' via golang-nuts
>> >> <golan...@googlegroups.com> wrote:
>> >> >
>> >> > import "github.com/pkg/errors"
>> >> >
>> >> > should be
>> >> >
>> >> > import "errors"
>> >> >
>> >> > left over from testing, but makes no difference, as expected.
>> >>
>> >> What were you expecting?
>> >>
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google 
>> >> > Groups "golang-nuts" group.
>> >> > To unsubscribe from this group and stop receiving emails from it, send 
>> >> > an email to golan...@googlegroups.com.
>> >> > To view this discussion on the web visit 
>> >> > https://groups.google.com/d/msgid/golang-nuts/0d654a7b-dc92-432b-b152-91bd6ba68cf2o%40googlegroups.com.
>> >
>> > --
>> > You received this message because you are subscribed to the Google Groups 
>> > "golang-nuts" group.
>> > To unsubscribe from this group and stop receiving emails from it, send an 
>> > email to golan...@googlegroups.com.
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msgid/golang-nuts/d240fe1d-fce5-41c5-b45e-03bb5caa9e9eo%40googlegroups.com.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/844c4220-5e2a-466f-8a9d-63904fd11e89o%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2RqosPT_BqpyCpgRyK-Dt47hr74g8Brn3%2BzYccXEhwZ0jug%40mail.gmail.com.

Reply via email to