Skip to content

FT7 F-3: HTML controller で throw した DomainException を JSON ではなく HTML template で出す #314

@hideyukiMORI

Description

@hideyukiMORI

Source: FT7 (#308 / PR #311) — F-3。
Severity: medium / Kind: design-trade-off / Decision: fix-in-framework。

現状

`htdocs/index.php:42-46` の `Xion\DomainException` catch は常に `JsonResponder` 経由で JSON envelope を emit する。HTML 側 (`*Action`) で `throw new DomainException('TODO-NOT-FOUND')` するとブラウザに JSON が飛ぶ。

やること

  • `DomainException` catch も `RouteContext::isAction()` で分岐する
  • HTML 側は envelope の `errorCode` を Smarty 変数として template/error/domain.tpl (or 4xx.tpl) に渡してレンダリングする
  • REST 側は現状維持

受け入れ条件

  • HTML `*Action` で `throw new DomainException('TODO-NOT-FOUND')` → HTML 404 ページが返る (template 介在)
  • REST `*Rest` で同じ throw → JSON envelope (現行どおり)
  • `composer test` / `composer test:http` green

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions