[#1517] cli: Print the reason of ape manager error
All checks were successful
DCO action / DCO (pull_request) Successful in 3m18s
Tests and linters / Staticcheck (pull_request) Successful in 4m30s
Tests and linters / gopls check (pull_request) Successful in 4m40s
Pre-commit hooks / Pre-commit (pull_request) Successful in 4m55s
Build / Build Components (pull_request) Successful in 5m28s
Vulncheck / Vulncheck (pull_request) Successful in 5m54s
Tests and linters / Lint (pull_request) Successful in 6m17s
Tests and linters / Run gofumpt (pull_request) Successful in 6m17s
Tests and linters / Tests (pull_request) Successful in 7m56s
Tests and linters / Tests with -race (pull_request) Successful in 7m59s
Vulncheck / Vulncheck (push) Successful in 2m22s
Build / Build Components (push) Successful in 2m58s
Tests and linters / Run gofumpt (push) Successful in 2m55s
Tests and linters / Staticcheck (push) Successful in 3m2s
Pre-commit hooks / Pre-commit (push) Successful in 3m9s
Tests and linters / Lint (push) Successful in 3m47s
Tests and linters / gopls check (push) Successful in 3m43s
Tests and linters / Tests (push) Successful in 4m25s
Tests and linters / Tests with -race (push) Successful in 4m55s

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2024-11-22 15:19:51 +03:00
parent 99f9e59de9
commit 1ed7ab75fb

View file

@ -26,13 +26,15 @@ func ExitOnErr(cmd *cobra.Command, errFmt string, err error) {
_ = iota
internal
aclDenied
apemanagerDenied
)
var (
code int
internalErr = new(sdkstatus.ServerInternal)
accessErr = new(sdkstatus.ObjectAccessDenied)
internalErr = new(sdkstatus.ServerInternal)
accessErr = new(sdkstatus.ObjectAccessDenied)
apemanagerErr = new(sdkstatus.APEManagerAccessDenied)
)
switch {
@ -41,6 +43,9 @@ func ExitOnErr(cmd *cobra.Command, errFmt string, err error) {
case errors.As(err, &accessErr):
code = aclDenied
err = fmt.Errorf("%w: %s", err, accessErr.Reason())
case errors.As(err, &apemanagerErr):
code = apemanagerDenied
err = fmt.Errorf("%w: %s", err, apemanagerErr.Reason())
default:
code = internal
}