Merge pull request #2647 from seefs001/feature/status-code-auto-disable

feat: status code auto-disable configuration
This commit is contained in:
Seefs
2026-01-12 18:47:45 +08:00
committed by GitHub
parent 22b9438588
commit 41da848c56
13 changed files with 419 additions and 5 deletions

View File

@@ -130,6 +130,20 @@ func (e *NewAPIError) Error() string {
return e.Err.Error()
}
func (e *NewAPIError) ErrorWithStatusCode() string {
if e == nil {
return ""
}
msg := e.Error()
if e.StatusCode == 0 {
return msg
}
if msg == "" {
return fmt.Sprintf("status_code=%d", e.StatusCode)
}
return fmt.Sprintf("status_code=%d, %s", e.StatusCode, msg)
}
func (e *NewAPIError) MaskSensitiveError() string {
if e == nil {
return ""
@@ -144,6 +158,20 @@ func (e *NewAPIError) MaskSensitiveError() string {
return common.MaskSensitiveInfo(errStr)
}
func (e *NewAPIError) MaskSensitiveErrorWithStatusCode() string {
if e == nil {
return ""
}
msg := e.MaskSensitiveError()
if e.StatusCode == 0 {
return msg
}
if msg == "" {
return fmt.Sprintf("status_code=%d", e.StatusCode)
}
return fmt.Sprintf("status_code=%d, %s", e.StatusCode, msg)
}
func (e *NewAPIError) SetMessage(message string) {
e.Err = errors.New(message)
}