Replies: 1 comment 3 replies
-
One fairly common pattern is something like: private async Task<string> DoRequest(Func<ISomeApi, Task<string>> method)
{
try
{
return await method(api1);
}
catch (Exception x)
{
Log.AppendLine(x.Message);
if (x is HttpRequestException c && c.StatusCode == null) return "Check your Internet connection";
return x.Message;
}
} Then: var result1 = await DoRequest(x => x.Method1Async(param1, param2)); Another option is to use a RequestModifier, and catch exceptions in there. The downside is that you still need to return a |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
how to auto surround all requests by try-catch bloc?
example : force
to execute as:
Beta Was this translation helpful? Give feedback.
All reactions