mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-26 05:23:32 -06:00
[bugfix] internal server error on search not found (#1590)
* add error value wrapping, include status code / not found flags from transport errors, update error usages Signed-off-by: kim <grufwub@gmail.com> * add code commenting for gtserror functions Signed-off-by: kim <grufwub@gmail.com> --------- Signed-off-by: kim <grufwub@gmail.com>
This commit is contained in:
parent
f518f649f8
commit
d8d5818b47
9 changed files with 108 additions and 37 deletions
|
|
@ -24,6 +24,8 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtserror"
|
||||
)
|
||||
|
||||
func (t *transport) DereferenceMedia(ctx context.Context, iri *url.URL) (io.ReadCloser, int64, error) {
|
||||
|
|
@ -46,7 +48,8 @@ func (t *transport) DereferenceMedia(ctx context.Context, iri *url.URL) (io.Read
|
|||
|
||||
// Check for an expected status code
|
||||
if rsp.StatusCode != http.StatusOK {
|
||||
return nil, 0, fmt.Errorf("GET request to %s failed: %s", iriStr, rsp.Status)
|
||||
err := fmt.Errorf("GET request to %s failed: %s", iriStr, rsp.Status)
|
||||
return nil, 0, gtserror.WithStatusCode(err, rsp.StatusCode)
|
||||
}
|
||||
|
||||
return rsp.Body, rsp.ContentLength, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue