API のエラー形式がエンドポイントごとに違うとクライアントが辛い。ProblemDetails(RFC 7807 系)で type / title / status / detail を揃えるのが定石。
[ApiController] の自動 400 も ProblemDetails 形式になりやすいIExceptionHandler で 5xx も同じ形に寄せるtype … エラー種別の URI またはタグtitle … 短い見出しstatus … HTTP ステータスdetail … 人が読む説明(本番は控えめに)extensions … トレース ID など追加欄return Results.Problem(
title: "Order not found",
detail: "指定の注文は存在しません",
statusCode: StatusCodes.Status404NotFound,
type: "https://example.com/errors/order-not-found");
// コントローラなら
return Problem(
title: "Validation failed",
statusCode: 400);
関連: モデルバインディング 400 の切り分けとセットで使うと早い。