Skip to content

Commit

Permalink
[Formation] Update exeption error. (#18)
Browse files Browse the repository at this point in the history
feat : upgrade error message
  • Loading branch information
Angel-Dijoux authored Dec 26, 2023
1 parent 562856b commit 6c02c40
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/business_logic/formation/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class NoOnisepAPIException(Exception):
"""
Raised when we cannot communicate wit Onisep API
"""

pass
5 changes: 4 additions & 1 deletion src/business_logic/formation/scrap/utils/get_onisep_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# https://opendata.onisep.fr/data/5fa591127f501/2-ideo-formations-initiales-en-france.htm
import requests
from src.business_logic.formation import HEADERS, ONISEP_URL
from src.business_logic.formation.exceptions import NoOnisepAPIException


DATASET = "5fa591127f501"
Expand All @@ -12,4 +13,6 @@ def get_onisep_data(params: str) -> dict:
response = requests.get(url, headers=HEADERS)
if response.status_code == 200:
return response.json()
raise Exception("Onisep API is down.", response.status_code)
raise NoOnisepAPIException(
f"status: {response.status_code} \n message : Onisep API is down. \n dataset : {DATASET} \n headers : {HEADERS} "
)

0 comments on commit 6c02c40

Please sign in to comment.