forked from TrueCloudLab/frostfs-node
[#648] objsvc/delete: Handle errors in Go style
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
d2084ece41
commit
f8ba60aa0c
4 changed files with 62 additions and 181 deletions
|
@ -29,27 +29,17 @@ func (s *Service) Delete(ctx context.Context, prm Prm) error {
|
|||
|
||||
exec.setLogger(s.log)
|
||||
|
||||
exec.execute(ctx)
|
||||
|
||||
return exec.statusError.err
|
||||
return exec.execute(ctx)
|
||||
}
|
||||
|
||||
func (exec *execCtx) execute(ctx context.Context) {
|
||||
func (exec *execCtx) execute(ctx context.Context) error {
|
||||
exec.log.Debug(logs.ServingRequest)
|
||||
|
||||
// perform local operation
|
||||
exec.executeLocal(ctx)
|
||||
exec.analyzeStatus()
|
||||
}
|
||||
|
||||
func (exec *execCtx) analyzeStatus() {
|
||||
// analyze local result
|
||||
switch exec.status {
|
||||
case statusOK:
|
||||
exec.log.Debug(logs.OperationFinishedSuccessfully)
|
||||
default:
|
||||
exec.log.Debug(logs.OperationFinishedWithError,
|
||||
zap.String("error", exec.err.Error()),
|
||||
)
|
||||
if err := exec.executeLocal(ctx); err != nil {
|
||||
exec.log.Debug(logs.OperationFinishedWithError, zap.String("error", err.Error()))
|
||||
return err
|
||||
}
|
||||
|
||||
exec.log.Debug(logs.OperationFinishedSuccessfully)
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue