Last active
July 27, 2018 14:22
-
-
Save marraia/89e742b756e6339abcb2b7b91f9ec6fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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