Skip to content

Commit

Permalink
fix: show all errors when reading cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed May 7, 2024
1 parent 9f64565 commit eecda0e
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions leetcode/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,7 @@ func (b *browserAuth) AddCredentials(req *http.Request) error {
log.Debug("reading cookies", "browser", store.Browser(), "file", store.FilePath())
cookies, err := store.ReadCookies(filters...)
if err != nil {
if !os.IsNotExist(err) {
errs = append(errs, err)
}
log.Debug("failed to read cookies", "error", err)
continue
}
if len(cookies) < 2 {
log.Debug("no cookie found", "browser", store.Browser())
errs = append(errs, err)
continue
}
for _, cookie := range cookies {
Expand All @@ -190,7 +183,7 @@ func (b *browserAuth) AddCredentials(req *http.Request) error {
}
}
if b.LeetCodeSession == "" || b.CsrfToken == "" {
log.Debug("no cookie found", "browser", store.Browser(), "domain", domain)
errs = append(errs, fmt.Errorf("LeetCode cookies not found in %s", store.FilePath()))
continue
}
log.Info("read LeetCode cookies", "browser", store.Browser(), "domain", domain)
Expand Down

0 comments on commit eecda0e

Please sign in to comment.