Commit: 5d543c2
Parent: 635a0eb

Return 404 when `GetById` cannot find the sought order

Mårten Åsberg committed on 2026-02-21 at 18:24
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>