From 9edacef768138826e586c0023d5785041dd9f649 Mon Sep 17 00:00:00 2001 From: Elara Musayelyan Date: Wed, 4 Oct 2023 20:54:36 -0700 Subject: [PATCH] Rename LemmyError to Error to remove stutter --- errors.go | 6 +++--- lemmy.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/errors.go b/errors.go index da11838..8331082 100644 --- a/errors.go +++ b/errors.go @@ -14,12 +14,12 @@ func (he HTTPError) Error() string { return fmt.Sprintf("%d %s", he.Code, http.StatusText(he.Code)) } -// LemmyError represents an error returned by the Lemmy API -type LemmyError struct { +// Error represents an error returned by the Lemmy API +type Error struct { ErrStr string Code int } -func (le LemmyError) Error() string { +func (le Error) Error() string { return fmt.Sprintf("%d %s: %s", le.Code, http.StatusText(le.Code), le.ErrStr) } diff --git a/lemmy.go b/lemmy.go index 538eac5..538d91c 100644 --- a/lemmy.go +++ b/lemmy.go @@ -148,7 +148,7 @@ type emptyResponse struct { // resError returns an error if the the response contains an error func resError(res *http.Response, err Optional[string]) error { if errstr, ok := err.Value(); ok { - return LemmyError{ + return Error{ Code: res.StatusCode, ErrStr: errstr, }