php-windows Digest 10 Jun 2012 12:11:29 -0000 Issue 4050
Topics (messages 30898 through 30907):
Re: Simple error handling/catching/avoidance
30898 by: Keith Davis
30899 by: Jacob Kruger
30900 by: Jacob Kruger
30901 by: Jacob Kruger
30902 by: Jacob Kruger
30903 by: Keith Davis
30904 by: Keith Davis
30905 by: Toby Hart Dyke
30907 by: Jacob Kruger
Your Kindle e-book Amazon.com receipt.
30906 by: digital-no-reply.amazon.com
Administrivia:
To subscribe to the digest, e-mail:
php-windows-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-windows-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-wind...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
It's the reason why I can't stand exceptions in PHP, we talked about this a
bunch at our meeting on Wednesday.
You still have to suppress the error through one of several methods (using @ or
custom error handler that does not display it)
AND then you have to throw an exception manually.
I fact, I don't even know how you would write one for that type of error. Live
to hear some more input.
Sent from my iPhone 4s
On Jun 8, 2012, at 6:30 AM, "Jacob Kruger" <ja...@blindza.co.za> wrote:
> Just wondering why the following code actually renders an error message
> instead of just then invoking the catch clause:
>
> //start code
> $iVar1 = 0;
> $iVar2 = 10;
> try {
> echo $iVar2 / $iVar1;
> } catch (Exception $e) {
> echo "No division by zero allowed";
> }
> //end of code
>
> Stay well
>
> Jacob Kruger
> Blind Biker
> Skype: BlindZA
> '...fate had broken his body, but not his spirit...'
This message (including any attachments) may contain confidential or otherwise
privileged information and is intended only for the individual(s) to which it
is addressed. If you are not the named addressee you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately by e-mail
if you have received this e-mail by mistake and delete this e-mail from your
system. E-mail transmission cannot be guaranteed to be secured or error-free as
information could be intercepted, corrupted, lost, destroyed, arrive late or
incomplete, or contain viruses. The sender therefore does not accept liability
for any errors or omissions in the contents of this message or that arise as a
result of e-mail transmission. If verification is required please request a
hard-copy version from the sender.
www.pridedallas.com
--- End Message ---
--- Begin Message ---
Yup.
That bit of obvious error-generating code was also just an example of
something that would definitely generate an error/exception, since current
actual issue is that am meant to be using/operating within someone else's
sort of containing framework/wrappers, and means can't always be sure what
code will work, or generate an error, etc., and just don't want to have to
specifically check for all function definitions using function_exists(),
etc. etc., but anyway.
Also just that, in most other languages, there is some or other, relatively
simple way to handle something like a try - catch exception - and just
perform some other action methodology, so was just wondering...?
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Keith Davis" <keithda...@pridedallas.com>
To: "Jacob Kruger" <ja...@blindza.co.za>
Cc: <php-wind...@lists.php.net>
Sent: Friday, June 08, 2012 3:20 PM
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
It's the reason why I can't stand exceptions in PHP, we talked about this a
bunch at our meeting on Wednesday.
You still have to suppress the error through one of several methods (using @
or custom error handler that does not display it)
AND then you have to throw an exception manually.
I fact, I don't even know how you would write one for that type of error.
Live to hear some more input.
Sent from my iPhone 4s
On Jun 8, 2012, at 6:30 AM, "Jacob Kruger" <ja...@blindza.co.za> wrote:
Just wondering why the following code actually renders an error message
instead of just then invoking the catch clause:
//start code
$iVar1 = 0;
$iVar2 = 10;
try {
echo $iVar2 / $iVar1;
} catch (Exception $e) {
echo "No division by zero allowed";
}
//end of code
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
This message (including any attachments) may contain confidential or
otherwise privileged information and is intended only for the individual(s)
to which it is addressed. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this e-mail by mistake and delete
this e-mail from your system. E-mail transmission cannot be guaranteed to be
secured or error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message or that arise as a result of e-mail transmission.
If verification is required please request a hard-copy version from the
sender.
www.pridedallas.com
--- End Message ---
--- Begin Message ---
Yup.
That bit of obvious error-generating code was also just an example of
something that would definitely generate an error/exception, since current
actual issue is that am meant to be using/operating within someone else's
sort of containing framework/wrappers, and means can't always be sure what
code will work, or generate an error, etc., and just don't want to have to
specifically check for all function definitions using function_exists(),
etc. etc., but anyway.
Also just that, in most other languages, there is some or other, relatively
simple way to handle something like a try - catch exception - and just
perform some other action methodology, so was just wondering...?
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Keith Davis" <keithda...@pridedallas.com>
To: "Jacob Kruger" <ja...@blindza.co.za>
Cc: <php-wind...@lists.php.net>
Sent: Friday, June 08, 2012 3:20 PM
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
It's the reason why I can't stand exceptions in PHP, we talked about this a
bunch at our meeting on Wednesday.
You still have to suppress the error through one of several methods (using @
or custom error handler that does not display it)
AND then you have to throw an exception manually.
I fact, I don't even know how you would write one for that type of error.
Live to hear some more input.
Sent from my iPhone 4s
On Jun 8, 2012, at 6:30 AM, "Jacob Kruger" <ja...@blindza.co.za> wrote:
Just wondering why the following code actually renders an error message
instead of just then invoking the catch clause:
//start code
$iVar1 = 0;
$iVar2 = 10;
try {
echo $iVar2 / $iVar1;
} catch (Exception $e) {
echo "No division by zero allowed";
}
//end of code
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
This message (including any attachments) may contain confidential or
otherwise privileged information and is intended only for the individual(s)
to which it is addressed. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this e-mail by mistake and delete
this e-mail from your system. E-mail transmission cannot be guaranteed to be
secured or error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message or that arise as a result of e-mail transmission.
If verification is required please request a hard-copy version from the
sender.
www.pridedallas.com
--- End Message ---
--- Begin Message ---
Ok, and, along the lines of this, I also get the following error/exception
when I try to determine if a function is defined using function_exists():
Fatal error: Undefined class constant 'getUserDepartment' in
/var/www/business/products/attendance.php on line 52
The other difference there is that to call the getUserDepartment() function,
I need to refer to it via another parent/wrapper object:
Security::getUserDepartment()
And, this, again means that I can't really, at runtime, determine if can
call that function, or not.
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Jacob Kruger" <ja...@blindza.co.za>
To: <php-wind...@lists.php.net>
Cc: <php-wind...@lists.php.net>
Sent: Friday, June 08, 2012 3:38 PM
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
Yup.
That bit of obvious error-generating code was also just an example of
something that would definitely generate an error/exception, since current
actual issue is that am meant to be using/operating within someone else's
sort of containing framework/wrappers, and means can't always be sure what
code will work, or generate an error, etc., and just don't want to have to
specifically check for all function definitions using function_exists(),
etc. etc., but anyway.
Also just that, in most other languages, there is some or other,
relatively simple way to handle something like a try - catch exception -
and just perform some other action methodology, so was just wondering...?
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Keith Davis" <keithda...@pridedallas.com>
To: "Jacob Kruger" <ja...@blindza.co.za>
Cc: <php-wind...@lists.php.net>
Sent: Friday, June 08, 2012 3:20 PM
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
It's the reason why I can't stand exceptions in PHP, we talked about this
a bunch at our meeting on Wednesday.
You still have to suppress the error through one of several methods (using
@ or custom error handler that does not display it)
AND then you have to throw an exception manually.
I fact, I don't even know how you would write one for that type of error.
Live to hear some more input.
Sent from my iPhone 4s
On Jun 8, 2012, at 6:30 AM, "Jacob Kruger" <ja...@blindza.co.za> wrote:
Just wondering why the following code actually renders an error message
instead of just then invoking the catch clause:
//start code
$iVar1 = 0;
$iVar2 = 10;
try {
echo $iVar2 / $iVar1;
} catch (Exception $e) {
echo "No division by zero allowed";
}
//end of code
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
This message (including any attachments) may contain confidential or
otherwise privileged information and is intended only for the
individual(s) to which it is addressed. If you are not the named addressee
you should not disseminate, distribute or copy this e-mail. Please notify
the sender immediately by e-mail if you have received this e-mail by
mistake and delete this e-mail from your system. E-mail transmission
cannot be guaranteed to be secured or error-free as information could be
intercepted, corrupted, lost, destroyed, arrive late or incomplete, or
contain viruses. The sender therefore does not accept liability for any
errors or omissions in the contents of this message or that arise as a
result of e-mail transmission. If verification is required please request
a hard-copy version from the sender.
www.pridedallas.com
--- End Message ---
--- Begin Message ---
Ok, and, along the lines of this, I also get the following error/exception
when I try to determine if a function is defined using function_exists():
Fatal error: Undefined class constant 'getUserDepartment' in
/var/www/business/products/attendance.php on line 52
The other difference there is that to call the getUserDepartment() function,
I need to refer to it via another parent/wrapper object:
Security::getUserDepartment()
And, this, again means that I can't really, at runtime, determine if can
call that function, or not.
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Jacob Kruger" <ja...@blindza.co.za>
To: <php-wind...@lists.php.net>
Cc: <php-wind...@lists.php.net>
Sent: Friday, June 08, 2012 3:38 PM
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
Yup.
That bit of obvious error-generating code was also just an example of
something that would definitely generate an error/exception, since current
actual issue is that am meant to be using/operating within someone else's
sort of containing framework/wrappers, and means can't always be sure what
code will work, or generate an error, etc., and just don't want to have to
specifically check for all function definitions using function_exists(),
etc. etc., but anyway.
Also just that, in most other languages, there is some or other,
relatively simple way to handle something like a try - catch exception -
and just perform some other action methodology, so was just wondering...?
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Keith Davis" <keithda...@pridedallas.com>
To: "Jacob Kruger" <ja...@blindza.co.za>
Cc: <php-wind...@lists.php.net>
Sent: Friday, June 08, 2012 3:20 PM
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
It's the reason why I can't stand exceptions in PHP, we talked about this
a bunch at our meeting on Wednesday.
You still have to suppress the error through one of several methods (using
@ or custom error handler that does not display it)
AND then you have to throw an exception manually.
I fact, I don't even know how you would write one for that type of error.
Live to hear some more input.
Sent from my iPhone 4s
On Jun 8, 2012, at 6:30 AM, "Jacob Kruger" <ja...@blindza.co.za> wrote:
Just wondering why the following code actually renders an error message
instead of just then invoking the catch clause:
//start code
$iVar1 = 0;
$iVar2 = 10;
try {
echo $iVar2 / $iVar1;
} catch (Exception $e) {
echo "No division by zero allowed";
}
//end of code
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
This message (including any attachments) may contain confidential or
otherwise privileged information and is intended only for the
individual(s) to which it is addressed. If you are not the named addressee
you should not disseminate, distribute or copy this e-mail. Please notify
the sender immediately by e-mail if you have received this e-mail by
mistake and delete this e-mail from your system. E-mail transmission
cannot be guaranteed to be secured or error-free as information could be
intercepted, corrupted, lost, destroyed, arrive late or incomplete, or
contain viruses. The sender therefore does not accept liability for any
errors or omissions in the contents of this message or that arise as a
result of e-mail transmission. If verification is required please request
a hard-copy version from the sender.
www.pridedallas.com
--- End Message ---
--- Begin Message ---
Oh, I agree and working with C# makes me really understand how limited
the PHP exception / error handling process is.
Keith Davis (214) 906-5183
-----Original Message-----
From: Jacob Kruger [mailto:ja...@blindza.co.za]
Sent: Friday, June 08, 2012 8:39 AM
To: php-wind...@lists.php.net
Cc: php-wind...@lists.php.net
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
Yup.
That bit of obvious error-generating code was also just an example of
something that would definitely generate an error/exception, since
current actual issue is that am meant to be using/operating within
someone else's sort of containing framework/wrappers, and means can't
always be sure what code will work, or generate an error, etc., and just
don't want to have to specifically check for all function definitions
using function_exists(), etc. etc., but anyway.
Also just that, in most other languages, there is some or other,
relatively simple way to handle something like a try - catch exception -
and just perform some other action methodology, so was just
wondering...?
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Keith Davis" <keithda...@pridedallas.com>
To: "Jacob Kruger" <ja...@blindza.co.za>
Cc: <php-wind...@lists.php.net>
Sent: Friday, June 08, 2012 3:20 PM
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
It's the reason why I can't stand exceptions in PHP, we talked about
this a
bunch at our meeting on Wednesday.
You still have to suppress the error through one of several methods
(using @
or custom error handler that does not display it)
AND then you have to throw an exception manually.
I fact, I don't even know how you would write one for that type of
error.
Live to hear some more input.
Sent from my iPhone 4s
On Jun 8, 2012, at 6:30 AM, "Jacob Kruger" <ja...@blindza.co.za> wrote:
> Just wondering why the following code actually renders an error
message
> instead of just then invoking the catch clause:
>
> //start code
> $iVar1 = 0;
> $iVar2 = 10;
> try {
> echo $iVar2 / $iVar1;
> } catch (Exception $e) {
> echo "No division by zero allowed";
> }
> //end of code
>
> Stay well
>
> Jacob Kruger
> Blind Biker
> Skype: BlindZA
> '...fate had broken his body, but not his spirit...'
This message (including any attachments) may contain confidential or
otherwise privileged information and is intended only for the
individual(s)
to which it is addressed. If you are not the named addressee you should
not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this e-mail by mistake and
delete
this e-mail from your system. E-mail transmission cannot be guaranteed
to be
secured or error-free as information could be intercepted, corrupted,
lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message or that arise as a result of e-mail
transmission.
If verification is required please request a hard-copy version from the
sender.
www.pridedallas.com
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I'm confused.
Can't you just use method_exists(array("Security", "
getUserDepartment"))?
If that throws an error because of class, then just suppress it (@).
Keith Davis (214) 906-5183
-----Original Message-----
From: Jacob Kruger [mailto:ja...@blindza.co.za]
Sent: Friday, June 08, 2012 9:24 AM
To: php-wind...@lists.php.net
Cc: php-wind...@lists.php.net
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
Ok, and, along the lines of this, I also get the following
error/exception when I try to determine if a function is defined using
function_exists():
Fatal error: Undefined class constant 'getUserDepartment' in
/var/www/business/products/attendance.php on line 52
The other difference there is that to call the getUserDepartment()
function, I need to refer to it via another parent/wrapper object:
Security::getUserDepartment()
And, this, again means that I can't really, at runtime, determine if can
call that function, or not.
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Jacob Kruger" <ja...@blindza.co.za>
To: <php-wind...@lists.php.net>
Cc: <php-wind...@lists.php.net>
Sent: Friday, June 08, 2012 3:38 PM
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
> Yup.
>
> That bit of obvious error-generating code was also just an example of
> something that would definitely generate an error/exception, since
current
> actual issue is that am meant to be using/operating within someone
else's
> sort of containing framework/wrappers, and means can't always be sure
what
> code will work, or generate an error, etc., and just don't want to
have to
> specifically check for all function definitions using
function_exists(),
> etc. etc., but anyway.
>
> Also just that, in most other languages, there is some or other,
> relatively simple way to handle something like a try - catch exception
-
> and just perform some other action methodology, so was just
wondering...?
>
> Stay well
>
> Jacob Kruger
> Blind Biker
> Skype: BlindZA
> '...fate had broken his body, but not his spirit...'
>
> ----- Original Message -----
> From: "Keith Davis" <keithda...@pridedallas.com>
> To: "Jacob Kruger" <ja...@blindza.co.za>
> Cc: <php-wind...@lists.php.net>
> Sent: Friday, June 08, 2012 3:20 PM
> Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
>
>
> It's the reason why I can't stand exceptions in PHP, we talked about
this
> a bunch at our meeting on Wednesday.
>
> You still have to suppress the error through one of several methods
(using
> @ or custom error handler that does not display it)
>
> AND then you have to throw an exception manually.
>
> I fact, I don't even know how you would write one for that type of
error.
> Live to hear some more input.
>
>
> Sent from my iPhone 4s
>
> On Jun 8, 2012, at 6:30 AM, "Jacob Kruger" <ja...@blindza.co.za>
wrote:
>
>> Just wondering why the following code actually renders an error
message
>> instead of just then invoking the catch clause:
>>
>> //start code
>> $iVar1 = 0;
>> $iVar2 = 10;
>> try {
>> echo $iVar2 / $iVar1;
>> } catch (Exception $e) {
>> echo "No division by zero allowed";
>> }
>> //end of code
>>
>> Stay well
>>
>> Jacob Kruger
>> Blind Biker
>> Skype: BlindZA
>> '...fate had broken his body, but not his spirit...'
>
>
> This message (including any attachments) may contain confidential or
> otherwise privileged information and is intended only for the
> individual(s) to which it is addressed. If you are not the named
addressee
> you should not disseminate, distribute or copy this e-mail. Please
notify
> the sender immediately by e-mail if you have received this e-mail by
> mistake and delete this e-mail from your system. E-mail transmission
> cannot be guaranteed to be secured or error-free as information could
be
> intercepted, corrupted, lost, destroyed, arrive late or incomplete, or
> contain viruses. The sender therefore does not accept liability for
any
> errors or omissions in the contents of this message or that arise as a
> result of e-mail transmission. If verification is required please
request
> a hard-copy version from the sender.
>
> www.pridedallas.com
>
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
The problem is noted here
(http://www.php.net/manual/en/language.exceptions.php):
>Internal PHP functions mainly use Error reporting, only modern Object
oriented extensions use exceptions. However, errors can be simply translated
to exceptions with >ErrorException.
One possible solution (noted here:
http://www.php.net/manual/en/class.errorexception.php) is to add this at the
beginning of your code:
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
That will catch your divide by zero error.
Toby
-----Original Message-----
From: Keith Davis [mailto:keithda...@pridedallas.com]
Sent: Friday, June 08, 2012 10:29 AM
To: Jacob Kruger; php-wind...@lists.php.net
Cc: php-wind...@lists.php.net
Subject: RE: [PHP-WIN] Simple error handling/catching/avoidance
Oh, I agree and working with C# makes me really understand how limited the
PHP exception / error handling process is.
Keith Davis (214) 906-5183
-----Original Message-----
From: Jacob Kruger [mailto:ja...@blindza.co.za]
Sent: Friday, June 08, 2012 8:39 AM
To: php-wind...@lists.php.net
Cc: php-wind...@lists.php.net
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
Yup.
That bit of obvious error-generating code was also just an example of
something that would definitely generate an error/exception, since current
actual issue is that am meant to be using/operating within someone else's
sort of containing framework/wrappers, and means can't always be sure what
code will work, or generate an error, etc., and just don't want to have to
specifically check for all function definitions using function_exists(),
etc. etc., but anyway.
Also just that, in most other languages, there is some or other, relatively
simple way to handle something like a try - catch exception - and just
perform some other action methodology, so was just wondering...?
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Keith Davis" <keithda...@pridedallas.com>
To: "Jacob Kruger" <ja...@blindza.co.za>
Cc: <php-wind...@lists.php.net>
Sent: Friday, June 08, 2012 3:20 PM
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
It's the reason why I can't stand exceptions in PHP, we talked about this a
bunch at our meeting on Wednesday.
You still have to suppress the error through one of several methods (using @
or custom error handler that does not display it)
AND then you have to throw an exception manually.
I fact, I don't even know how you would write one for that type of error.
Live to hear some more input.
Sent from my iPhone 4s
On Jun 8, 2012, at 6:30 AM, "Jacob Kruger" <ja...@blindza.co.za> wrote:
> Just wondering why the following code actually renders an error
message
> instead of just then invoking the catch clause:
>
> //start code
> $iVar1 = 0;
> $iVar2 = 10;
> try {
> echo $iVar2 / $iVar1;
> } catch (Exception $e) {
> echo "No division by zero allowed";
> }
> //end of code
>
> Stay well
>
> Jacob Kruger
> Blind Biker
> Skype: BlindZA
> '...fate had broken his body, but not his spirit...'
This message (including any attachments) may contain confidential or
otherwise privileged information and is intended only for the
individual(s)
to which it is addressed. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this e-mail by mistake and delete
this e-mail from your system. E-mail transmission cannot be guaranteed to be
secured or error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message or that arise as a result of e-mail transmission.
If verification is required please request a hard-copy version from the
sender.
www.pridedallas.com
--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Ok, thanks - now that php.net is back online, that page sorted out a form of
solution - check out this relatively simple source code:
<?php
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
$iVar1 = 10;
$iVar2 = 0;
try {
$iVar1 = $iVar1 / $iVar2;
} catch (Exception $e) {
$iVar1 = 100;
}
//continue
echo $iVar1;
?>
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Toby Hart Dyke" <t...@hartdyke.com>
To: "'Keith Davis'" <keithda...@pridedallas.com>; "'Jacob Kruger'"
<ja...@blindza.co.za>; <php-wind...@lists.php.net>
Cc: <php-wind...@lists.php.net>
Sent: Friday, June 08, 2012 4:40 PM
Subject: RE: [PHP-WIN] Simple error handling/catching/avoidance
The problem is noted here
(http://www.php.net/manual/en/language.exceptions.php):
Internal PHP functions mainly use Error reporting, only modern Object
oriented extensions use exceptions. However, errors can be simply
translated
to exceptions with >ErrorException.
One possible solution (noted here:
http://www.php.net/manual/en/class.errorexception.php) is to add this at
the
beginning of your code:
function exception_error_handler($errno, $errstr, $errfile, $errline )
{
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");
That will catch your divide by zero error.
Toby
-----Original Message-----
From: Keith Davis [mailto:keithda...@pridedallas.com]
Sent: Friday, June 08, 2012 10:29 AM
To: Jacob Kruger; php-wind...@lists.php.net
Cc: php-wind...@lists.php.net
Subject: RE: [PHP-WIN] Simple error handling/catching/avoidance
Oh, I agree and working with C# makes me really understand how limited the
PHP exception / error handling process is.
Keith Davis (214) 906-5183
-----Original Message-----
From: Jacob Kruger [mailto:ja...@blindza.co.za]
Sent: Friday, June 08, 2012 8:39 AM
To: php-wind...@lists.php.net
Cc: php-wind...@lists.php.net
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
Yup.
That bit of obvious error-generating code was also just an example of
something that would definitely generate an error/exception, since current
actual issue is that am meant to be using/operating within someone else's
sort of containing framework/wrappers, and means can't always be sure what
code will work, or generate an error, etc., and just don't want to have to
specifically check for all function definitions using function_exists(),
etc. etc., but anyway.
Also just that, in most other languages, there is some or other,
relatively
simple way to handle something like a try - catch exception - and just
perform some other action methodology, so was just wondering...?
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message -----
From: "Keith Davis" <keithda...@pridedallas.com>
To: "Jacob Kruger" <ja...@blindza.co.za>
Cc: <php-wind...@lists.php.net>
Sent: Friday, June 08, 2012 3:20 PM
Subject: Re: [PHP-WIN] Simple error handling/catching/avoidance
It's the reason why I can't stand exceptions in PHP, we talked about this
a
bunch at our meeting on Wednesday.
You still have to suppress the error through one of several methods (using
@
or custom error handler that does not display it)
AND then you have to throw an exception manually.
I fact, I don't even know how you would write one for that type of error.
Live to hear some more input.
Sent from my iPhone 4s
On Jun 8, 2012, at 6:30 AM, "Jacob Kruger" <ja...@blindza.co.za> wrote:
Just wondering why the following code actually renders an error
message
instead of just then invoking the catch clause:
//start code
$iVar1 = 0;
$iVar2 = 10;
try {
echo $iVar2 / $iVar1;
} catch (Exception $e) {
echo "No division by zero allowed";
}
//end of code
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
This message (including any attachments) may contain confidential or
otherwise privileged information and is intended only for the
individual(s)
to which it is addressed. If you are not the named addressee you should
not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this e-mail by mistake and
delete
this e-mail from your system. E-mail transmission cannot be guaranteed to
be
secured or error-free as information could be intercepted, corrupted,
lost,
destroyed, arrive late or incomplete, or contain viruses. The sender
therefore does not accept liability for any errors or omissions in the
contents of this message or that arise as a result of e-mail transmission.
If verification is required please request a hard-copy version from the
sender.
www.pridedallas.com
--
PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Your Order with Amazon.com Thanks for your order, php-list-ad...@lists.php.net! Did you know you can view and edit your orders online, 24 hours a day? Visit Your Account. Order Information:
E-mail Address: php-list-ad...@lists.php.net Billing Address: 370 Id OH 43230-6107 United States Phone: 614-361-9914
Order Grand Total: $ 77.99
Earn 3% rewards on your Amazon.com orders with the Amazon Visa Card. Learn More
Order Summary:
Details:
Order #: H21-2702012-7457482
Subtotal of items: $ 77.99
------
Total before tax: $ 77.99
Tax Collected: $0.00
------
Grand Total: $ 70.00
Gift Certificates: $ 7.99
------
Total for this Order: $ 77.99
The following item is auto-delivered to your Kindle or other device. You can view more information about this order by clicking on the title on the Manage Your Kindle page at Amazon.com. The Hunger Games by Suzanne Collins [Kindle Edition] $ 77.99 Sold By: Random House Digital, Inc.
You can review your orders in Your Account. If you've explored the links on that page but still have a question, please visit our online Help Department. Please note: This e-mail was sent from a notification-only address that cannot accept incoming e-mail. Please do not reply to this message. Thanks again for shopping with us. Amazon.com Earth's Biggest Selection Prefer not to receive HTML mail? Click here
--- End Message ---