Created
August 31, 2017 22:51
-
-
Save ChaosEngine/319c24c858d6b55cf8a7b8d293f0a828 to your computer and use it in GitHub Desktop.
Cancellationtoken Edge test case
This file contains hidden or 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
[HttpGet] | |
public async Task<IActionResult> Load(string sort, string order, string search, int limit, int offset, string extraParam) | |
{ | |
CancellationToken token = HttpContext.RequestAborted; | |
try | |
{ | |
var found = await _repo.SearchAsync(sort, order, search, offset, limit, token); | |
var result = new | |
{ | |
total = found.Count, | |
rows = found.Itemz | |
}; | |
var content = JsonConvert.SerializeObject(result, Formatting.None, | |
new JsonSerializerSettings() { MetadataPropertyHandling = MetadataPropertyHandling.Ignore }); | |
return Content(content, "application/json"); | |
} | |
catch (OperationCanceledException ex) | |
{ | |
_logger.LogError(ex, $"Cancelled {nameof(Load)}::{nameof(_repo.SearchAsync)}({sort}, {order}, {search}, {offset}, {limit}, {token})"); | |
return Ok(); | |
} | |
catch (Exception ex) | |
{ | |
_logger.LogError(ex, $"{nameof(Load)}::{nameof(_repo.SearchAsync)}({sort}, {order}, {search}, {offset}, {limit}, {token})"); | |
throw; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment