fix(api): fail fast on unexpected null document payload
This commit is contained in:
@@ -27,13 +27,7 @@ public sealed class DocumentsController(ISender sender) : ControllerBase
|
||||
public async Task<IActionResult> GetAsync([FromRoute] string id, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = await sender.Send(new GetDocumentQuery(id), cancellationToken);
|
||||
var data = response.Data;
|
||||
|
||||
if (data is null)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
|
||||
var data = response.Data ?? throw new InvalidOperationException("Document payload is unexpectedly null.");
|
||||
return File(data.Content, data.ContentType, data.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user