# Exception class feature request

- Thread: https://externals.io/message/6814
- Original archive: https://news-web.php.net/php.internals/6814
- Started by Greg Beaver on 2004-01-06T05:04:59+00:00
- Messages: 1
- 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

---

## #6814 — Greg Beaver — 2004-01-06T05:04:59+00:00

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

Hi,

I think my first attempt may have bounced, so I'm resending this.

I wonder if it would be a difficult thing to add in a third optional 
parameter to the constructor for Exception, which would accept an array 
of error-specific information.

I find that many errors I use have information embedded in the message 
which it would be nice to have in certain instances, such as when an 
error is triggered by an external entity and contains more information 
than just an error code.

$ex = new Exception('database error, dsn ' . $dsn, DATA_ERROR_CODE, 
array('dsn' => $dsn, 'mysql_message' => $errmsg, 'mysql_code' => $errcode));

I know that I can just append this after constructing the exception like so:

$ex->data = array('dsn' => $dsn, 'mysql_message' => $errmsg, 
'mysql_code' => $errcode));

or extend the Exception class to be OO pretty, but it would be nice to 
have such a thing standardized, as we can then count on the error data 
existing in a standard way across all apps that use PHP 5 Exceptions.

I realize this would be in 5.1, most likely, if it is implemented.

Thanks,
Greg
