|
|
|
|
|
by sacado2
2883 days ago
|
|
I don't know, most of the time, I add information to the error before propagating it: if f, err := os.Open(path); err != nil {
return nil, fmt.Errorf("could not open path: %v", err)
}
This is the vast majority of my error management code in go. Is rust less verbose in this regard? AFAIK, the question mark operator is equivalent to `if err != nil { return nil, err }`. |
|
1. Define a conversion between the two errors that adds the context.
2. Use .map_err() at the callsite to do the transformation there.