{"modulePath":"github.com/erda-project/erda","version":"v1.0.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package errorresp\n\nPackage errorresp 封装了错误定义\n\n## Functions\n\n```go\nfunc ErrResp(e error) (httpserver.Responser, error)\n```\nErrResp 根据 error 转为一个 http error response.\n\n```go\nfunc ErrWrite(e error, w http.ResponseWriter) error\n```\nErrWrite 根据 error 写入标准错误格式\n\n```go\nfunc IsNotFound(e error) bool\n```\n\n## Types\n\n```go\ntype APIError struct {\n\t// contains filtered or unexported fields\n}\n```\nAPIError 接口错误\n\n```go\nfunc New(options ...Option) *APIError\n```\nNew 新建接口错误\n\n```go\nfunc (e *APIError) AccessDenied() *APIError\n```\nAccessDenied 无权限\n\n```go\nfunc (e *APIError) AlreadyExists() *APIError\n```\nAlreadyExists 资源已存在\n\n```go\nfunc (e *APIError) Code() string\n```\nCode 错误码\n\n```go\nfunc (e *APIError) Error() string\n```\nError 错误信息\n\n```go\nfunc (e *APIError) ErrorVerificationCode(err error) *APIError\n```\nErrorVerificationCode 验证码错误\n\n```go\nfunc (e *APIError) HttpCode() int\n```\nHttpCode HTTP错误码\n\n```go\nfunc (e *APIError) InternalError(err error) *APIError\n```\nInternalError 异常\n\n```go\nfunc (e *APIError) InvalidParameter(err interface{}) *APIError\n```\nInvalidParameter 参数错误\n\n```go\nfunc (e *APIError) InvalidState(err string) *APIError\n```\nInvalidState 状态异常\n\n```go\nfunc (e *APIError) MissingParameter(err string) *APIError\n```\nMissingParameter 缺少参数\n\n```go\nfunc (e *APIError) NotFound() *APIError\n```\nNotFound 资源不存在\n\n```go\nfunc (e *APIError) NotLogin() *APIError\n```\nNotLogin 未登录\n\n```go\nfunc (e *APIError) Render(localeResource *i18n.LocaleResource) string\n```\n\n```go\nfunc (e *APIError) ToResp() httpserver.Responser\n```\nToResp 根据 APIError 转为一个 http error response.\n\n```go\nfunc (e *APIError) Write(w http.ResponseWriter) error\n```\nWrite 将错误写入 http.ResponseWriter\n\n```go\ntype MetaMessage struct {\n\tKey     string\n\tArgs    []interface{}\n\tDefault string\n}\n```\n\n```go\ntype Option func(*APIError)\n```\nOption 可选参数\n\n```go\nfunc WithCode(httpCode int, code string) Option\n```\n\n```go\nfunc WithMessage(msg string) Option\n```\nWithMessage 初始化 msg\n\n```go\nfunc WithTemplateMessage(template, defaultValue string, args ...interface{}) Option\n```\nWithTemplateMessage 初始化 msg\n\n","path":"github.com/erda-project/erda/pkg/httpserver/errorresp","name":"errorresp","synopsis":"Package errorresp 封装了错误定义","isRedistributable":true}
