# Proper return after throwing exception

- Thread: https://externals.io/message/48732
- Original archive: https://news-web.php.net/php.internals/48732
- Started by Pieter de Zwart on 2010-06-10T19:41:29+00:00
- Messages: 5
- 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

---

## #48732 — Pieter de Zwart — 2010-06-10T19:41:29+00:00

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

Hey guys,

Another n00b question: What is the proper way to return from a function
after throwing an exception? My code looks like:

zend_throw_exception(amqp_connection_exception_class_entry, "blah blah
blah", 0 TSRMLS_CC);
return; 

Should I instead RETURN_FALSE from there?

Thanks,
Pieter

---

## #48733 — Alexey Zakhlestin — 2010-06-10T19:53:43+00:00

URL: https://externals.io/message/48732#48733 · In reply to: #48732

> Hey guys,
> 
> Another n00b question: What is the proper way to return from a function
> after throwing an exception? My code looks like:
> 
> zend_throw_exception(amqp_connection_exception_class_entry, "blah blah
> blah", 0 TSRMLS_CC);
> return; 
> 
> Should I instead RETURN_FALSE from there?

It doesn't really matter, as return value will never be checked.
"return" should be enough


-- 
Alexey Zakhlestin
http://www.milkfarmsoft.com/

---

## #48740 — Daniel Convissor — 2010-06-11T17:24:16+00:00

URL: https://externals.io/message/48732#48740 · In reply to: #48732

Hi Pieter:


> 
> zend_throw_exception(amqp_connection_exception_class_entry, "blah blah
> blah", 0 TSRMLS_CC);
> return; 

These kinds of questions (regarding how to use PHP) should be asked on 
the php-general list.  The internals list you wrote to is for discussions 
of how to make PHP.

Anyway, the "return" line in your code can never be reached, so should 
not be there at all.

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409

---

## #48742 — Hannes Magnusson — 2010-06-11T17:34:54+00:00

URL: https://externals.io/message/48732#48742 · In reply to: #48740

On Fri, Jun 11, 2010 at 19:24, Daniel Convissor
<danielc@analysisandsolutions.com> wrote:
> Hi Pieter:
>
> 
> > […]
>
> These kinds of questions (regarding how to use PHP) should be asked on
> the php-general list.  The internals list you wrote to is for discussions
> of how to make PHP.

Which part of "zend_throw_exception()" sounds like a php-general@ question?

I think you misread his question :)

-Hannes

---

## #48754 — Daniel Convissor — 2010-06-12T14:34:11+00:00

URL: https://externals.io/message/48732#48754 · In reply to: #48742

Hi Hannes:


> 
> Which part of "zend_throw_exception()" sounds like a php-general@ question?

DOH!

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409
