# default exceptions, interfaces, etc.

- Thread: https://externals.io/message/168
- Original archive: https://news-web.php.net/php.internals/168
- Started by l0t3k on 2003-03-23T05:53:01+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

---

## #168 — l0t3k — 2003-03-23T05:53:01+00:00

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

Sterling,
    have you thought of public accessors (maybe even macros) for exception
properties. this is for the benefit of extension authors who want to
subclass. right now i have to basically copy the code for the constructor to
my new class, or resort using call_user_function_ex.
for my extension classes i usually do something like this :

    int myclass_init_zval(zval *return_val,int foo, char *bar, void *etc);
/* create a myclass obj stored in return_val */

and put it in the header so i can create an instance of the class from
anywhere i need to.  the constructor function also calls this.

   another idea is basic macros

 /* set up the common properties. subclasses can add others. also set
EG(exception) to return_zval if not set */
   ZEND_RAISE_EXCEPTION_EX(return_zval, exception_or_subclass_ce, code,
message, ...)

/* for extension authors to handle exceptions  in C */
   ZEND_LOWER_EXCEPTION()
/* just to be less arcane */
   ZEND_HAS_EXCEPTION()   (NULL !=  EG(exception))
