[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:
kim 2023-03-06 09:38:43 +00:00 committed by GitHub
commit d8d5818b47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 108 additions and 37 deletions

View file

@ -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