1 Star 0 Fork 0

nanjo_fan / goharbor-client

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
quota_errors.go 811 Bytes
一键复制 编辑 原始数据 按行查看 历史
王帆 提交于 2023-02-13 09:15 . 修改依赖
package quota
import (
"net/http"
"github.com/go-openapi/runtime"
"gitee.com/nanjo-fan/goharbor-client/pkg/errors"
)
// handleSwaggerQuotaErrors takes a swagger generated error as input,
// which usually does not contain any form of error message,
// and outputs a new error with a proper message.
func handleSwaggerQuotaErrors(in error) error {
t, ok := in.(*runtime.APIError)
if ok {
switch t.Code {
case http.StatusBadRequest:
return &errors.ErrQuotaIllegalIDFormat{}
case http.StatusUnauthorized:
return &errors.ErrQuotaUnauthorized{}
case http.StatusForbidden:
return &errors.ErrQuotaNoPermission{}
case http.StatusNotFound:
return &errors.ErrQuotaUnknownResource{}
case http.StatusInternalServerError:
return &errors.ErrQuotaInternalServerErrors{}
}
}
return nil
}
Go
1
https://gitee.com/nanjo-fan/goharbor-client.git
git@gitee.com:nanjo-fan/goharbor-client.git
nanjo-fan
goharbor-client
goharbor-client
v1.0.2

搜索帮助