mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 00:46:42 +00:00
Merge pull request #2647 from seefs001/feature/status-code-auto-disable
feat: status code auto-disable configuration
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user