> For the complete documentation index, see [llms.txt](https://quantumphp.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://quantumphp.gitbook.io/docs/packages/tracer/overview.md).

# Overview

Tracer is Quantum’s global error-handling layer.

Use it during bootstrap to convert PHP runtime errors into exceptions and send uncaught throwables through a consistent CLI or web response path.

## What it provides

* `ErrorHandler` for registration and runtime routing
* `ExceptionSeverityResolver` for logger severity selection
* `WebExceptionRenderer` for debug and production error views
* `StackTraceFormatter` for source snippets in debug trace pages

## Quick setup

```php
use Quantum\Tracer\ErrorHandler;

$handler = new ErrorHandler();
$handler->setup($logger);
```

## Runtime behavior

After setup:

* enabled PHP errors become `ErrorException` instances
* uncaught throwables are routed by runtime (`cli` or web)
* web requests return HTTP 500 for uncaught exceptions
* production web requests log the exception before rendering the response

## Debug and production output

* CLI debug: class, message, file/line, and full trace
* CLI production: exception message in the terminal output
* Web debug: `errors/trace` partial with formatted stack trace data
* Web production: `errors/500` partial

## Practical constraints

* Production logging happens in the web exception path.
* Uncaught web exceptions use a 500 response.
* Source snippets appear when the filesystem adapter can read local source files.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://quantumphp.gitbook.io/docs/packages/tracer/overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
