Skip to content

Standardise error creation in gitaly services

Pavlo Strokov requested to merge ps-errors-management into master

During lifetime of the gitaly project there were changes into the way how we work with errors. But not always the old code was aligned with new ways of managing errors. The latest state is usage of the error wrapping with the error creation by helper package functions.
The helpers allow to send a proper error code back to the RPC caller by unwrapping chain of wrapped errors.
Also lot of errors were returned without proper wrapping. That is why we have lot of Undefined error codes returned by the gitaly service. The change solves that problem by using helper package, but there still might be some places that require attention.

Text of some errors aligned to be the same for the same operation called, like object reader creation, etc.
The redundant RPC name is removed from the error text as the caller knows for sure which method is called and also that info is tracked in logs for each RPC invocation.
The incorrect usage of the fmt.Errorf() where no arguments used for text formatting replaced with simple errors.New().
A couple of RPCs may now return more correct status codes as the checks for the "not found" or "bad argument" were added, instead of returning just Internal code.

Closes: #4471 (closed)

Merge request reports