Skip to content

Commit

Permalink
Optimize error handling methods (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstmdev authored Dec 31, 2024
1 parent a6502b0 commit ede1cd9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion driver/sftp/sftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (sd *sftpDriver) reconnectIfLost(f func() error) error {
}

func (sd *sftpDriver) isClosed(err error) bool {
return err == sftp.ErrSSHFxConnectionLost
return errors.Is(err, sftp.ErrSSHFxConnectionLost)
}

func (sd *sftpDriver) MkdirAll(path string) error {
Expand Down
5 changes: 3 additions & 2 deletions internal/toplist/toplist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package toplist

import (
"bytes"
"errors"
"sync"
"testing"

Expand All @@ -12,14 +13,14 @@ func TestTopList_WithCapZero(t *testing.T) {
// desc
capacity := 0
_, err := New(capacity)
if err != errInvalidCapacity {
if !errors.Is(err, errInvalidCapacity) {
t.Errorf("[desc] test toplist with zero capacity error, expect get an error")
}

// asc
capacity = 0
_, err = NewOrderByAsc(capacity)
if err != errInvalidCapacity {
if !errors.Is(err, errInvalidCapacity) {
t.Errorf("[asc] test toplist with zero capacity error, expect get an error")
}
}
Expand Down

0 comments on commit ede1cd9

Please sign in to comment.