# Extend bundled exceptions

- Thread: https://externals.io/message/78899
- Original archive: https://news-web.php.net/php.internals/78899
- Started by Mathieu D. on 2014-11-14T07:39:30+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #78899 — Mathieu D. — 2014-11-14T07:39:30+00:00

URL: https://externals.io/message/78899#78899

PHP is lacking of some elemental exceptions. One obvious example would be
FileNotFoundException.

Java has a FileNotFoundException,
C# has a FileNotFoundException,
Python has a FileNotFoundError, ...

Why doesn't PHP provide a bundled FileNotFoundException or at least a more
general IOException?

Because of this shortcoming, developers must address this lack by creating
the same custom exceptions repeatedly.

This is a suggestion/open discussion, sorry if I didn't post it in the
right mailing list.

 - Mathieu

---

## #78906 — Andrea Faulds — 2014-11-14T11:32:27+00:00

URL: https://externals.io/message/78899#78906 · In reply to: #78899

> 
> 
> PHP is lacking of some elemental exceptions. One obvious example would be
> FileNotFoundException.
> 
> Java has a FileNotFoundException,
> C# has a FileNotFoundException,
> Python has a FileNotFoundError, ...
> 
> Why doesn't PHP provide a bundled FileNotFoundException or at least a more
> general IOException?

Presumably this is because most of PHP’s I/O stuff still uses procedural APIs with error return values.

One of the things I’d like to see happen, but don’t have the time to do myself, is get rid of the IS_RESOURCE type from PHP for PHP 7, and replace all instances with objects. As part of this, we’d need to convert streams to using objects, which would give us an opportunity to create a new OOP stream API, learning from our past mistakes and which uses exceptions. As part of that, I’m sure we’d add some I/O exceptions.

--
Andrea Faulds
http://ajf.me/

---

## #78917 — Larry Garfield — 2014-11-15T17:53:18+00:00

URL: https://externals.io/message/78899#78917 · In reply to: #78906

> One of the things I’d like to see happen, but don’t have the time to do myself, is get rid of the IS_RESOURCE type from PHP for PHP 7, and replace all instances with objects. As part of this, we’d need to convert streams to using objects, which would give us an opportunity to create a new OOP stream API, learning from our past mistakes and which uses exceptions. As part of that, I’m sure we’d add some I/O exceptions.
>
> --
> Andrea Faulds
> http://ajf.me/

Yes please!!

(I'm not a C dev, but would be happy to help brainstorm/rubber duck with 
someone who is on this front if there is interest.)

--Larry Garfield
