Skip to content

Commit

Permalink
Make RateLimitError implement error rather than making a pointer to i…
Browse files Browse the repository at this point in the history
…t implement the error
  • Loading branch information
LHeggy committed Apr 17, 2024
1 parent 85875d8 commit 9ac6f7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ type RateLimitedError struct {
RetryAfter time.Duration
}

func (e *RateLimitedError) Error() string {
func (e RateLimitedError) Error() string {
return fmt.Sprintf("slack rate limit exceeded, retry after %s", e.RetryAfter)
}

func (e *RateLimitedError) Retryable() bool {
func (e RateLimitedError) Retryable() bool {
return true
}

Expand Down
8 changes: 8 additions & 0 deletions misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package slack

import (
"context"
"errors"
"log"
"net/http"
"net/url"
Expand Down Expand Up @@ -104,3 +105,10 @@ func TestRetryable(t *testing.T) {
}
}
}

func TestCanUseErrorsAs(t *testing.T) {
_ = errors.As(errors.New("error"), &RateLimitedError{})
_ = errors.As(errors.New("error"), &StatusCodeError{})
_ = errors.As(errors.New("error"), &SlackError{})
// no panic means we're good
}

0 comments on commit 9ac6f7c

Please sign in to comment.