Skip to content

Commit

Permalink
Use Enums for status codes (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Blank authored Nov 1, 2023
1 parent 9bd8227 commit 81c886d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lrclib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import warnings
from http import HTTPStatus
from typing import Any, Dict, Optional

import requests
Expand Down Expand Up @@ -61,11 +62,11 @@ def _make_request(
response.raise_for_status()
except requests.exceptions.HTTPError as exc:
response = exc.response # type: ignore
if response.status_code == 404:
if response.status_code == HTTPStatus.NOT_FOUND:
raise NotFoundError(response) from exc
if response.status_code == 429:
if response.status_code == HTTPStatus.TOO_MANY_REQUESTS:
raise RateLimitError(response) from exc
if response.status_code == 400:
if response.status_code == HTTPStatus.BAD_REQUEST:
raise IncorrectPublishTokenError(response) from exc
if 500 <= response.status_code < 600:
raise ServerError(response) from exc
Expand Down

0 comments on commit 81c886d

Please sign in to comment.