Solarion
Honorary Master
- Joined
- Nov 14, 2012
- Messages
- 28,051
- Reaction score
- 17,804
Hey guys. This is something I'm coming back to because in the past I've been a bit lazy and simply let the exceptions get logged where the httpclient makes the calls.
I'm wanting to implement something more user friendly. I have created a generic httpclient wrapper in a shared Infrastructure library. Then I'm injecting that into second reusable utility class which handles all the calls, dto resolving where needed and simply returns the basic nulls, empty lists, bools and int for the various calls. I've made it reusable because several projects need to call the API. Whether it's a good plan or not I'm open to suggestions.
What I'm not sure about is what to do with the exceptions like 404 or even just the response codes in general. Should I hand then in the utility classes, the wrapper class or in the calling project itself?
If in the calling project, I end up with a case of var user = response.data(This is using a Result wrapper)
Then for checking the response it will be a case of:
If(response.success)
{
user = response.data;
}
else
{
//not sure what to do here, throw it or log it?
}
I'm typing from a phone so it looks crap sorry.
I am away from my pc atm but will certainly share the code and implementation tomorrow. I just want to get a feel for what you guys do. Your feedback is appreciated as this is something I've never quite pinned down.
I'm wanting to implement something more user friendly. I have created a generic httpclient wrapper in a shared Infrastructure library. Then I'm injecting that into second reusable utility class which handles all the calls, dto resolving where needed and simply returns the basic nulls, empty lists, bools and int for the various calls. I've made it reusable because several projects need to call the API. Whether it's a good plan or not I'm open to suggestions.
What I'm not sure about is what to do with the exceptions like 404 or even just the response codes in general. Should I hand then in the utility classes, the wrapper class or in the calling project itself?
If in the calling project, I end up with a case of var user = response.data(This is using a Result wrapper)
Then for checking the response it will be a case of:
If(response.success)
{
user = response.data;
}
else
{
//not sure what to do here, throw it or log it?
}
I'm typing from a phone so it looks crap sorry.
I am away from my pc atm but will certainly share the code and implementation tomorrow. I just want to get a feel for what you guys do. Your feedback is appreciated as this is something I've never quite pinned down.