diff --git a/CHANGELOG.md b/CHANGELOG.md
index ed5202a..497c655 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,7 @@
 - Added Issue and Pull Request Templates
 - Added [Code of Conduct](https://github.com/ucfopen/canvasapi/blob/develop/CODE_OF_CONDUCT.md)
 - Added CODEOWNERS file
+- Added generic error handling for unhandled 4XX+ HTTP errors
 
 ### Deprecation Warnings
 
@@ -33,6 +34,7 @@
 
 - Fixed an issue where creating an external tool did not properly send parameters to Canvas. (Thanks, [@altgilbers](https://github.com/altgilbers))
 - Fixed an issue where getting Quiz Submissions would only return up to the first 10 results (Thanks,[@Mike-Nahmias](https://github.com/Mike-Nahmias))
+- Fixed an issue where unhandled 4XX and 5XX HTTP errors would cause a JSONDecodeError
 
 ## [0.12.0] - 2019-04-03
 
diff --git a/canvasapi/requester.py b/canvasapi/requester.py
index 41650a3..1b6e0e1 100644
--- a/canvasapi/requester.py
+++ b/canvasapi/requester.py
@@ -109,8 +109,11 @@ class Requester(object):
             raise ResourceDoesNotExist('Not Found')
         elif response.status_code == 409:
             raise Conflict(response.text)
-        elif response.status_code == 500:
-            raise CanvasException("API encountered an error processing your request")
+        elif response.status_code > 400:
+            # generic catch-all for error codes
+            raise CanvasException(
+                "Encountered an error: status code {}".format(response.status_code)
+            )
 
         return response
 

Implement 503 Handling
Upon receiving a 503 response from Canvas, the library returns a `json.decoder.JSONDecodeError` instead of something more useful.

Implement handling for 503 response.

It's probably worth implementing generic handling for all 4xx and 5xx responses.
diff --git a/tests/fixtures/requests.json b/tests/fixtures/requests.json
index 08ee7d1..09bbfd0 100644
--- a/tests/fixtures/requests.json
+++ b/tests/fixtures/requests.json
@@ -38,6 +38,24 @@
 		"data": {},
 		"status_code": 500
 	},
+	"502": {
+		"method": "ANY",
+		"endpoint": "502",
+		"data": {},
+		"status_code": 502
+	},
+	"503": {
+		"method": "ANY",
+		"endpoint": "503",
+		"data": {},
+		"status_code": 503
+	},
+	"absurd": {
+		"method": "ANY",
+		"endpoint": "absurd",
+		"data": {},
+		"status_code": 9001
+	},
 	"delete": {
 		"method": "DELETE",
 		"endpoint": "fake_delete_request",
diff --git a/tests/test_requester.py b/tests/test_requester.py
index e5be5b6..c9adfae 100644
--- a/tests/test_requester.py
+++ b/tests/test_requester.py
@@ -146,3 +146,15 @@ class TestRequester(unittest.TestCase):
 
         with self.assertRaises(CanvasException):
             self.requester.request('GET', '500')
+
+    def test_request_generic(self, m):
+        register_uris({'requests': ['502', '503', 'absurd']}, m)
+
+        with self.assertRaises(CanvasException):
+            self.requester.request('GET', '502')
+
+        with self.assertRaises(CanvasException):
+            self.requester.request('GET', '503')
+
+        with self.assertRaises(CanvasException):
+            self.requester.request('GET', 'absurd')

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov pytest-flake8 pytest-mock requests_mock
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
-e git+https://github.com/ucfopen/canvasapi.git@39d8349de740964934bdf8c4809eae78adf3bd97#egg=canvasapi
certifi==2025.1.31
charset-normalizer==3.4.1
coverage==7.8.0
exceptiongroup==1.2.2
flake8==7.2.0
idna==3.10
iniconfig==2.1.0
mccabe==0.7.0
packaging==24.2
pluggy==1.5.0
pycodestyle==2.13.0
pyflakes==3.3.1
pytest==8.3.5
pytest-cov==6.0.0
pytest-flake8==1.3.0
pytest-mock==3.14.0
pytz==2025.2
requests==2.32.3
requests-mock==1.12.1
six==1.17.0
tomli==2.2.1
urllib3==2.3.0

name: canvasapi
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - coverage==7.8.0
      - exceptiongroup==1.2.2
      - flake8==7.2.0
      - idna==3.10
      - iniconfig==2.1.0
      - mccabe==0.7.0
      - packaging==24.2
      - pluggy==1.5.0
      - pycodestyle==2.13.0
      - pyflakes==3.3.1
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - pytest-flake8==1.3.0
      - pytest-mock==3.14.0
      - pytz==2025.2
      - requests==2.32.3
      - requests-mock==1.12.1
      - six==1.17.0
      - tomli==2.2.1
      - urllib3==2.3.0
prefix: /opt/conda/envs/canvasapi

tests/test_requester.py::TestRequester::test_request_generic
tests/test_requester.py::TestRequester::test_request_400 tests/test_requester.py::TestRequester::test_request_401_InvalidAccessToken tests/test_requester.py::TestRequester::test_request_401_Unauthorized tests/test_requester.py::TestRequester::test_request_404 tests/test_requester.py::TestRequester::test_request_409 tests/test_requester.py::TestRequester::test_request_500 tests/test_requester.py::TestRequester::test_request_cache tests/test_requester.py::TestRequester::test_request_cache_clear_after_5 tests/test_requester.py::TestRequester::test_request_delete tests/test_requester.py::TestRequester::test_request_get tests/test_requester.py::TestRequester::test_request_get_datetime tests/test_requester.py::TestRequester::test_request_lowercase_boolean tests/test_requester.py::TestRequester::test_request_post tests/test_requester.py::TestRequester::test_request_post_datetime tests/test_requester.py::TestRequester::test_request_put
canvasapi/requester.py CHANGELOG.md
canvasapi/requester.py CHANGELOG.md