# Error handling

Typeset.sh attempts to render your document even when errors occur, such as incorrect use of CSS properties or unsupported features. These errors are caught and stored within the result object for further handling, e.g. logging.

Similar, the standard UriResolver also catches any exceptions, such as file not found or access denied, and stores them in the UriResolver instance.

However, some errors may still prevent the document from rendering, in which case a try-catch block can be utilized. The example provided demonstrates how to dump all errors as additional headers.

```php
try {
    $html = <<<HTML
        <p>Hello,</p>
        <p>This is an simple example.</p>
    HTML;
    
    $resolveUri = \Typesetsh\UriResolver::all();
    $result = \Typesetsh\createPdf($html, $resolveUri);

    $data = $result->asString();
    header('Content-Type: application/pdf');
    header('Content-Length: ' . strlen($data));
    header("Content-Disposition:inline;filename=hello.pdf");
    
    /* Merge PDF errors and resolver errors */
    foreach ([...$result->issues, ...$resolveUri->errors] as $issue) {
        header("X-PDF-Warning: ".$issue->getMessage());
    }

    echo $data;

} catch (Exception $exception) {
    // Snap!
    http_response_code(500);
    echo "Error!";
}

```


---

# Agent Instructions: 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:

```
GET https://docs.typeset.sh/advanced-guides/error-handling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
