Skip to content

FT7 F-2: 未捕捉 Throwable を JSON envelope / HTML template にマッピングする #313

@hideyukiMORI

Description

@hideyukiMORI

Source: FT7 (#308 / PR #311) — F-2。
Severity: medium / Kind: feature-gap / Decision: fix-in-framework。

現状

`htdocs/index.php:47-52` の top-level `\Throwable` catch は `text/plain` で 500 を返す。REST/HTML どちらの caller も同じ平文を受け取り、ADR-0003 envelope も HTML template も使われない。さらに `APP_DEBUG=1` (non-prod default) では raw exception message が response body に漏れる。

やること

  • `RouteContext::isAction()` / `isRest()` で分岐し、REST → `ApiFailureEnvelope` (`INTERNAL-ERROR` 等)、HTML → `template/error/500.tpl`
  • `template/error/500.tpl` (最低限の Smarty テンプレ) を framework に追加
  • `APP_DEBUG` の振る舞いはそのまま (本 issue では「漏れ」自体は議論しない、別 issue 候補)
  • `docs/development/error-codes.md` に `INTERNAL-ERROR` 等の catalog 行を追加

受け入れ条件

  • REST 側で uncaught `RuntimeException` を起こすと `{Result, Data:{status:'failure', errorCode:'INTERNAL-ERROR'}}` が返る
  • HTML 側で同じ exception を起こすと `template/error/500.tpl` の HTML が返る
  • 既存 HTTP smoke test (`tests/Http/HttpErrorTest.php` 等) を緑のまま拡張

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