Thx, examples helped allot in understanding

On Thursday, October 24, 2019 at 6:53:32 PM UTC+2, Jake Montgomery wrote:
>
> I have not done much with the new errors stuff, but I'll try to help. 
>
> I assume you have read https://github.com/golang/go/wiki/ErrorValueFAQ  
> and https://blog.golang.org/go1.13-errors. There may be other posts as 
> well. 
>
> These new error functions, Is() and As() are about error types. It looks 
> like you are trying to transform an error of type PathErr into another 
> error of type PathErr with a different value. That's not how it works. 
>
> I think most of the time As() will work because the error wraps another 
> error of a different type. In that case the error should implement Unwrap() 
> not As(). If your error encapsulates multiple error types, then you would 
> need to implement As(). At least that is my understanding. For example, 
> taking your code, and modifying it, so that PathErr can also be treated as 
> an OtherErr could look like https://play.golang.org/p/qa4VU0PEP3v. But 
> again, since there is only one type encompassed in PathErr, I think this 
> might be more easily done with Unwrap like this: 
> https://play.golang.org/p/v4gDgtlNxcQ
>
> Good luck. 
>  
>
> On Thursday, October 24, 2019 at 4:26:25 AM UTC-4, Gert wrote:
>>
>> Hi, I fail to understand how the custom As is suppose to work?
>>
>> see example https://play.golang.org/p/tjuItX5dHoJ
>>
>>

-- 
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/f2257101-3c6f-4808-987b-3817e69733b3%40googlegroups.com.

Reply via email to