Skip to content

[RFC] Add Markdown format support for exception pages #61797

@vasilvestre

Description

@vasilvestre

Description

This proposal suggests adding a new markdown format for rendering exception pages in Symfony. Currently, Symfony supports formats like html, json, xml, etc., for its error pages. The addition of a markdown format would provide a structured, human-readable, and easily parsable output, which is particularly beneficial for modern development workflows involving AI/LLM-based tools and command-line debugging.

Problem Statement

  • Difficult for Automated Parsing: The default HTML exception page is designed for browsers and is verbose, making it difficult for automated tools (like log aggregators or LLM-based debuggers) to parse reliably.

  • Limited Human Readability (in raw format): While json and xml formats are machine-readable, they are not as straightforward for a human to read quickly in a terminal (e.g., via curl).

  • Rise of LLM Tooling: As noted by @fabpot, Markdown is an excellent format for Large Language Models (LLMs) to ingest. Providing exceptions in this format would enable powerful new debugging and analysis tools that can summarize errors, suggest fixes, or categorize issues automatically.

Proposed Solution

I propose introducing a new markdown format for the exception_controller. This could work similarly to the existing formats.

A client could request the error in Markdown format by sending the appropriate Accept header:
Accept: text/markdown

Symfony's exception handler would detect this and render a new Twig template, such as exception.md.twig.

As discussed during API platform conf with @fabpot and @nicolas-grekas, a simple markdown support for this error would be enough, having a new encoder (to markdown) is not necessary.

Example

# 500 | RuntimeException

## An Error Occurred: "Something went wrong!"

- **Class**: `App\Service\MyService`
- **File**: `/path/to/project/src/Service/MyService.php`
- **Line**: `42`

### Stack Trace

1.  **`App\Service\MyService->doSomething()`**
    at `/path/to/project/src/Service/MyService.php:42`
2.  **`App\Controller\MyController->index()`**
    at `/path/to/project/src/Controller/MyController.php:18`
3.  ... *(trace continues)*

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFCRFC = Request For Comments (proposals about features that you want to be discussed)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions