# RFC: TidyException type for the tidy extension

- Status: Under discussion
- Authors: devnexen, devnexen@gmail.com
- Date: 2025-10-26
- Version: 0.1
- Implementation: https://github.com/php/php-src/pull/19417/files
- Original: https://wiki.php.net/rfc/tidyexception-for-tidy
- Page: https://externals.io/rfc/tidyexception-for-tidy
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

## Discussions on the mailing list

- [\[RFC\]\[Discussion\] Using TidyException new type for tidy extension](https://externals.io/message/128969.md) — started on 2025-10-26, 4 messages

---

## Introduction

The goal is to allow the tidy extension to have its own exception type, TidyException, with which can be used for the tidy(p) C api usage, thinking about this while working at updating tidy to throw exception rather than raising warnings.

## Proposal

Nothing fancy, the TidyException would be as follow :

```php
class TidyException extends Exception
{
}
```

At the moment, the extension raises an exception for the following :

- tidy\_parse\_file().
- tidy::parseFile().
- tidy::\_\_construct().

What can be done as alternative is to make a hierarchy of exceptions within a new Tidy namespace.

```php
namespace Tidy
{
...
    class TidyException extends Exception
    {
    }
}
```

## Examples

```php
try {
    $tidy->parseFile("does_not_exist.html");
} catch (TidyException $e) {
    // Cannot load "does_not_exist.html" into memory
    echo $e->getMessage(), PHP_EOL;
}
```

## Backward Incompatible Changes

- Before, the extension did not raise an exception, that's the opportunity to create this new exception.

## Proposed PHP Version(s)

- next PHP 8.x

## RFC Impact

- none outside of the tidy extension
