From f3cc35862a75953e7b49e04b545bd1a37eaf8f9f Mon Sep 17 00:00:00 2001 From: jiuxia211 <2064166368@qq.com> Date: Sat, 7 Dec 2024 21:06:29 +0800 Subject: [PATCH] fix: undefined error --- jwch.go | 8 ++++---- user.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/jwch.go b/jwch.go index 70ed3c3..6bc7e18 100644 --- a/jwch.go +++ b/jwch.go @@ -79,12 +79,12 @@ func (s *Student) NewRequest() *resty.Request { func (s *Student) GetWithIdentifier(url string) (*html.Node, error) { resp, err := s.NewRequest().SetHeader("Referer", constants.JwchReferer).SetQueryParam("id", s.Identifier).Get(url) if err != nil { - return nil, errno.IdentifierExpiredError.WithErr(err) + return nil, errno.CookieExpiredError.WithErr(err) } // 会话过期 TODO: 判断条件有点简陋 if strings.Contains(string(resp.Body()), "重新登录") { - return nil, errno.IdentifierExpiredError + return nil, errno.CookieExpiredError } return htmlquery.Parse(bytes.NewReader(resp.Body())) @@ -97,12 +97,12 @@ func (s *Student) PostWithIdentifier(url string, formData map[string]string) (*h s.NewRequest().EnableTrace() if err != nil { - return nil, errno.IdentifierExpiredError.WithErr(err) + return nil, errno.CookieExpiredError.WithErr(err) } // Identifier缺失 TODO: 判断条件有点简陋 if strings.Contains(string(resp.Body()), "处理URL失败") { - return nil, errno.IdentifierExpiredError + return nil, errno.CookieExpiredError } return htmlquery.Parse(strings.NewReader(strings.TrimSpace(string(resp.Body())))) diff --git a/user.go b/user.go index 5408f13..5756512 100644 --- a/user.go +++ b/user.go @@ -167,7 +167,7 @@ func (s *Student) CheckSession() error { res := htmlquery.FindOne(resp, `//*[@id="ContentPlaceHolder1_LB_xh"]`) if res == nil { - return errno.IdentifierExpiredError.WithErr(err) + return errno.CookieExpiredError.WithErr(err) } if htmlquery.OutputHTML(res, false) != s.ID {