You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# user/internal.py
from .services import UserService
def get_user():
try:
UserService.get_user()
except SomeIntegrationError:
# Do something
# artists/interfaces.py
from user.apis import UserAPI
def get_user():
return UserAPI.get_user()
What do you guys think it's the best way to handle this situation?
I'm thinking of just raise an exception on internal.py and ignore that we should return a Json or we could return a dict with an error key and check on interfaces if that key exists and then handle the error there. But I don't like either option.
The text was updated successfully, but these errors were encountered:
If the artists domain needed to handle the errors for their own case, I would also make the interface capture the error and handle it how it wants:
fromuser.apisimportUserAPI, UserErrordefget_user():
try:
returnUserAPI.get_user()
exceptUserError:
# Handle case specially for artists
As I said - they are my immediate thoughts, and might not prove useful.
I think returning an actual Exception if it is a software API is appropriate (I.e. - python code calling python code).
If it is an HTTP API, then UserAPI.get_user should return an object with a defined error format that artist/interfaces can look out for:
fromuser.apisimportUserAPIdefget_user():
response=UserAPI.get_user()
ifresponse.get('errors'):
# Handle errors in API responsereturnresponse
Considering the example:
What do you guys think it's the best way to handle this situation?
I'm thinking of just raise an exception on internal.py and ignore that we should return a Json or we could return a dict with an
error
key and check oninterfaces
if that key exists and then handle the error there. But I don't like either option.The text was updated successfully, but these errors were encountered: