Commit:
5d543c2Parent:
635a0ebReturn 404 when `GetById` cannot find the sought order
src/Walley.Checkout.Api/Controllers/OrdersController.cs
+1
-3
diff --git a/src/Walley.Checkout.Api/Controllers/OrdersController.cs b/src/Walley.Checkout.Api/Controllers/OrdersController.cs
index 6a94046..fa49233 100644
@@ -34,10 +34,8 @@ public class OrdersController : ControllerBase
[HttpGet("{id}")]
public async Task<ActionResult<Order>> GetById(string id)
{
// Task 4: This error handling needs improvement.
// Right now any issue results in a generic 500 from the exception middleware.
var order = await _orderService.GetOrderByIdAsync(id);
return Ok(order);
return order != null ? Ok(order) : NotFound();
}
/// <summary>