cach HttpRequestException
This commit is contained in:
@@ -39,20 +39,34 @@ namespace OnePeek.Api
|
||||
/// HTTP GET request to the specified uri
|
||||
/// </summary>
|
||||
public async Task<string> Get(Uri uri)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpResponseMessage responseMessage = await httpClient.GetAsync(uri);
|
||||
return await responseMessage.Content.ReadAsStringAsync();
|
||||
}
|
||||
catch (HttpRequestException exc)
|
||||
{
|
||||
throw new OnePeekApiException(exc.Message, exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// HTTP GET request (as stream) to the specified uri
|
||||
/// </summary>
|
||||
public async Task<Stream> GetStream(Uri uri)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpResponseMessage responseMessage = await httpClient.GetAsync(uri);
|
||||
return await responseMessage.Content.ReadAsStreamAsync();
|
||||
}
|
||||
catch (HttpRequestException exc)
|
||||
{
|
||||
throw new OnePeekApiException(exc.Message, exc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
|
||||
Reference in New Issue
Block a user