chore: cleanup handler

This commit is contained in:
Bastien Riviere 2024-02-09 19:36:05 +01:00
parent e9b7f7ab4b
commit 324a5b31e0
Signed by: babariviere
GPG key ID: 4E5F0839249F162E

View file

@ -27,10 +27,11 @@ func NewHandler(serverUrl string, queries *db.Queries) *handler {
func (h *handler) RedirectLongURL(ctx context.Context, params oas.RedirectLongURLParams) (oas.RedirectLongURLRes, error) {
res, err := h.queries.GetURLByHash(ctx, params.Hash)
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return &oas.RedirectLongURLNotFound{}, nil
}
switch {
case errors.Is(err, pgx.ErrNoRows):
return &oas.RedirectLongURLNotFound{}, nil
case err != nil:
return nil, fmt.Errorf("unable to fetch URL by hash: %w", err)
}