api_entreprise: standardize error handling (#72961)

This commit is contained in:
Emmanuel Cazenave 2023-01-05 12:37:21 +01:00
parent 56dd83c347
commit a1600961af
1 changed files with 6 additions and 4 deletions

View File

@ -120,10 +120,12 @@ class APIEntreprise(BaseResource):
)
if response.status_code != 200:
if data.get('error') == 'not_found':
return {
'err': 1,
'err_desc': data.get('message', 'not-found'),
}
raise APIError(
data.get('message', 'not-found'),
data={
'status_code': response.status_code,
},
)
raise APIError(
'API-entreprise returned a non 200 status %s: %s' % (response.status_code, data),
data={