Skip to content

Instantly share code, notes, and snippets.

@marraia
Last active July 27, 2018 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marraia/89e742b756e6339abcb2b7b91f9ec6fc to your computer and use it in GitHub Desktop.
Save marraia/89e742b756e6339abcb2b7b91f9ec6fc to your computer and use it in GitHub Desktop.
private FallbackPolicy<Image> FallbackPolicy()
{
return Policy
.Handle<HttpRequestException>()
//Método que será eecutado, caso a requisição dê erro
.FallbackAsync(ExecuteFallBack, async result =>
{
var msg =
$" STATUSCODE: {result.Result.StatusCode} |" +
$" REASONPHRASE: {result.Result.ReasonPhrase} |";
_log.LogWarning(msg);
});
}
private Task<Image> ExecuteFallBack(CancellationToken arg)
{
Image img = Image.FromFile("c:\\imagemPadrao.png");
return Task.FromResult(img);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment