1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-08 04:00:23 +08:00
This commit is contained in:
源文雨
2023-10-12 01:00:38 +09:00
parent de27ba9f2a
commit 3e595b0dee
4 changed files with 12 additions and 8 deletions

View File

@@ -35,7 +35,7 @@ func (bot *Bot) GetOpenAPI(ep, contenttype string, ptr any) error {
if resp.StatusCode == http.StatusNoContent {
return nil
}
if resp.StatusCode != http.StatusOK {
if resp.StatusCode >= http.StatusBadRequest {
return errors.Wrap(errors.New("code: "+strconv.Itoa(resp.StatusCode)+", msg: "+resp.Status), getCallerFuncName())
}
if ptr == nil {
@@ -67,7 +67,7 @@ func (bot *Bot) PutOpenAPI(ep, contenttype string, ptr any, body io.Reader) erro
if resp.StatusCode == http.StatusNoContent {
return nil
}
if resp.StatusCode != http.StatusOK {
if resp.StatusCode >= http.StatusBadRequest {
return errors.Wrap(errors.New("code: "+strconv.Itoa(resp.StatusCode)+", msg: "+resp.Status), getCallerFuncName())
}
if ptr == nil {
@@ -97,7 +97,7 @@ func (bot *Bot) DeleteOpenAPI(ep, contenttype string, body io.Reader) error {
if resp.StatusCode == http.StatusNoContent {
return nil
}
if resp.StatusCode != http.StatusOK {
if resp.StatusCode >= http.StatusBadRequest {
return errors.Wrap(errors.New("code: "+strconv.Itoa(resp.StatusCode)+", msg: "+resp.Status), getCallerFuncName())
}
return nil
@@ -119,7 +119,7 @@ func (bot *Bot) PostOpenAPI(ep, contenttype string, ptr any, body io.Reader) err
if resp.StatusCode == http.StatusNoContent {
return nil
}
if resp.StatusCode != http.StatusOK {
if resp.StatusCode >= http.StatusBadRequest {
return errors.Wrap(errors.New("code: "+strconv.Itoa(resp.StatusCode)+", msg: "+resp.Status), getCallerFuncName())
}
if ptr == nil {
@@ -151,7 +151,7 @@ func (bot *Bot) PatchOpenAPI(ep, contenttype string, ptr any, body io.Reader) er
if resp.StatusCode == http.StatusNoContent {
return nil
}
if resp.StatusCode != http.StatusOK {
if resp.StatusCode >= http.StatusBadRequest {
return errors.Wrap(errors.New("code: "+strconv.Itoa(resp.StatusCode)+", msg: "+resp.Status), getCallerFuncName())
}
if ptr == nil {