[PHP] Re: [PHP-DEV] Re: [PHP] Exceptions: function x throws Exception

2005-08-06 Thread Marcus Boerger
Hello Jochem,

  lookup the archieves. We have long ago decided agains that.

marcus

Friday, August 5, 2005, 2:26:04 PM, you wrote:

 Dear Internals,

 class FooBar { public function foo() throws Exception {} }
 function fooFoo() throws Exception {}

 this came up on php-generals and I wondered if anyone had time/cared
 to comment if it (as it does to me) seems like a good idea and/or whether it 
 is
 technically feasable. My thinking was that one could then use the reflection 
 API
 to determine whether functions/methods are capable of throwing exceptions and 
 or
 what kind - might be quite handy when using third party apps/classes
 (PEAR springs to mind.)

 thanks and regards,
 Jochem


 the rest is blabla aimed at php-generals

 Torgny Bjers wrote:
 Norbert Wenzel wrote:
 
If there is a class with a function, that might throw exceptions and
does NOT catch them, may I write that like in Java?

class FooClass {

public function foo() throws Exception {

 think about this, especially in terms of the Reflection API, it sounds
 like a really good idea (at least to me)


}

}

Or is there another possibility to tell a function throws an exception
and to force the caller to handle that exception?

thanks in advance,

Norbert

 
 
 Hello Norbert,
 
 The Java way doesn't work here. The best approach would be to simply run
 a try/catch/finally around the call to your function/method, and inside
 the function itself you do the following:
 
 if (...) { throw new Exception(My message.); } }
 

 indeed - bottom line is you have to know that a function/method/extension may
 throw. mostly you do know because:

 1. you wrote the code,
 2. or it's documented in the extension manual pages
 3. and/ro you hit an unacaught exception whilst developing.

 my approach to cover any oversights is to wrap every thing in a main 
 try/catch block
 just in case - keeping in mind that the idea is that this 'main' catch block 
 is never run
 is al goes well.

 Regards,
 Torgny
 




Best regards,
 Marcus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [PHP-DEV] Re: [PHP] Exceptions: function x throws Exception

2005-08-06 Thread Jochem Maas

Marcus Boerger wrote:

Hello Jochem,

  lookup the archieves. We have long ago decided agains that.


I'll take your word on it. :-) (shame on me for not searching harder
before asking)

thanks for replying.



marcus

Friday, August 5, 2005, 2:26:04 PM, you wrote:



Dear Internals,




class FooBar { public function foo() throws Exception {} }
function fooFoo() throws Exception {}




   this came up on php-generals and I wondered if anyone had time/cared
to comment if it (as it does to me) seems like a good idea and/or whether it is
technically feasable. My thinking was that one could then use the reflection API
to determine whether functions/methods are capable of throwing exceptions and or
what kind - might be quite handy when using third party apps/classes
(PEAR springs to mind.)




thanks and regards,
Jochem





the rest is blabla aimed at php-generals




Torgny Bjers wrote:


Norbert Wenzel wrote:



If there is a class with a function, that might throw exceptions and
does NOT catch them, may I write that like in Java?

class FooClass {

  public function foo() throws Exception {




think about this, especially in terms of the Reflection API, it sounds
like a really good idea (at least to me)




  }

}

Or is there another possibility to tell a function throws an exception
and to force the caller to handle that exception?

thanks in advance,

Norbert




Hello Norbert,

The Java way doesn't work here. The best approach would be to simply run
a try/catch/finally around the call to your function/method, and inside
the function itself you do the following:

if (...) { throw new Exception(My message.); } }





indeed - bottom line is you have to know that a function/method/extension may
throw. mostly you do know because:




1. you wrote the code,
2. or it's documented in the extension manual pages
3. and/ro you hit an unacaught exception whilst developing.




my approach to cover any oversights is to wrap every thing in a main try/catch 
block
just in case - keeping in mind that the idea is that this 'main' catch block is 
never run
is al goes well.




Regards,
Torgny







Best regards,
 Marcus



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Exceptions: function x throws Exception

2005-08-05 Thread Norbert Wenzel
If there is a class with a function, that might throw exceptions and 
does NOT catch them, may I write that like in Java?


class FooClass {

public function foo() throws Exception {

}

}

Or is there another possibility to tell a function throws an exception 
and to force the caller to handle that exception?


thanks in advance,

Norbert

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Exceptions: function x throws Exception

2005-08-05 Thread Torgny Bjers
Norbert Wenzel wrote:
 If there is a class with a function, that might throw exceptions and
 does NOT catch them, may I write that like in Java?
 
 class FooClass {
 
 public function foo() throws Exception {
 
 }
 
 }
 
 Or is there another possibility to tell a function throws an exception
 and to force the caller to handle that exception?
 
 thanks in advance,
 
 Norbert
 

Hello Norbert,

The Java way doesn't work here. The best approach would be to simply run
a try/catch/finally around the call to your function/method, and inside
the function itself you do the following:

if (...) { throw new Exception(My message.); } }

Regards,
Torgny

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Exceptions: function x throws Exception

2005-08-05 Thread Norbert Wenzel

Torgny Bjers wrote:

The Java way doesn't work here. The best approach would be to simply run
a try/catch/finally around the call to your function/method, and inside
the function itself you do the following:

if (...) { throw new Exception(My message.); } }


Hello Torgny,

Thanky you for your fast help.

Greetings,
Norbert

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Exceptions: function x throws Exception

2005-08-05 Thread Jochem Maas

Dear Internals,

class FooBar { public function foo() throws Exception {} }
function fooFoo() throws Exception {}

this came up on php-generals and I wondered if anyone had time/cared
to comment if it (as it does to me) seems like a good idea and/or whether it is
technically feasable. My thinking was that one could then use the reflection API
to determine whether functions/methods are capable of throwing exceptions and or
what kind - might be quite handy when using third party apps/classes
(PEAR springs to mind.)

thanks and regards,
Jochem


the rest is blabla aimed at php-generals

Torgny Bjers wrote:

Norbert Wenzel wrote:


If there is a class with a function, that might throw exceptions and
does NOT catch them, may I write that like in Java?

class FooClass {

   public function foo() throws Exception {


think about this, especially in terms of the Reflection API, it sounds
like a really good idea (at least to me)



   }

}

Or is there another possibility to tell a function throws an exception
and to force the caller to handle that exception?

thanks in advance,

Norbert




Hello Norbert,

The Java way doesn't work here. The best approach would be to simply run
a try/catch/finally around the call to your function/method, and inside
the function itself you do the following:

if (...) { throw new Exception(My message.); } }



indeed - bottom line is you have to know that a function/method/extension may
throw. mostly you do know because:

1. you wrote the code,
2. or it's documented in the extension manual pages
3. and/ro you hit an unacaught exception whilst developing.

my approach to cover any oversights is to wrap every thing in a main try/catch 
block
just in case - keeping in mind that the idea is that this 'main' catch block is 
never run
is al goes well.


Regards,
Torgny



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php