Skip to content

Commit

Permalink
add exception ConnectionError
Browse files Browse the repository at this point in the history
  • Loading branch information
alinnural committed Sep 28, 2020
1 parent 3e9d31b commit 4897a76
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions academy/website/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import json
from json.decoder import JSONDecodeError

from requests.exceptions import ConnectionError

from django.contrib.auth.decorators import login_required
from django.shortcuts import render, redirect, get_object_or_404
from django.template import loader
Expand Down Expand Up @@ -182,13 +184,13 @@ def home_custom(request):
courses = call_internal_api(
'get', url=settings.NOLSATU_COURSE_HOST + f'/api/list').json()
courses = courses[:3]
except JSONDecodeError:
except (JSONDecodeError, ConnectionError):
courses = []

try:
vendors = call_internal_api(
'get', url=settings.NOLSATU_COURSE_HOST + f'/api/vendorlist').json()
except JSONDecodeError:
except (JSONDecodeError, ConnectionError):
vendors = []

context = {
Expand Down

0 comments on commit 4897a76

Please sign in to comment.