#41012 [Bgs-Opn]: exception handling

2007-04-09 Thread perching_eagle at yahoo dot com
 ID:   41012
 User updated by:  perching_eagle at yahoo dot com
 Reported By:  perching_eagle at yahoo dot com
-Status:   Bogus
+Status:   Open
 Bug Type: *Compile Issues
 Operating System: windows xp
 PHP Version:  5.2.1
 New Comment:

well the logic behind exceptions is to help you handle ALL types of
errors and i will show you a similar example in python.

 python code:

 num=input('enter a number, do not enter zero:)
 try:
 print 34/int(num)
 except ZeroDivisionError:
 print error,you entered zero

 (if you enter 2) output: 17

 (if you enter 0) output: error, you entered zero
 
  #java does exactly the same thing.
 

simple code, i didn't have to explicitly throw any exception (using the
throw keyword) or include an if statement. this obeys the rule of keep
things simple, and the try keyword actually does something, as opposed
to being a mere decoration as it is now in PHP.


Previous Comments:


[2007-04-08 15:11:42] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Fatal errors are not exceptions and therefor try {} does nothing to 
catch them.



[2007-04-06 21:00:29] perching_eagle at yahoo dot com

?php
   $e=there is an error;
 try{
  throw new Exception ($e);//the throw can exist outside the try 
   //block (or simply, almost anywhere)
}
 try{
  $err=34/0;//the compiler should ignore this error
//it is legal because it is in a try block
 }
$error=34/0;//the compiler should act on this error
 ? //this error is illegal

  however zend engine will flag the error in the second try block
  (an abnormal behavior) instead of ignoring it.

note: when flagging other posters comments as bogus, give logical
reasons for doing so.



[2007-04-06 20:27:20] perching_eagle at yahoo dot com

why is not a bug?
this is an abnormal behavior, that restricts how you use the exception
class. if the try block can't force an erroreneous code to compile,
why do you have the try keyword anyway? the throw keyword could be
used outside a try block and also in a catch block or anywhere else
in the program. in a nutshell, the try keyword has no function at all
in php, if it does, what is it?

the documentation at php.net does not explain the function of the try
keyword in php.



[2007-04-06 18:55:16] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.



[2007-04-06 18:43:25] perching_eagle at yahoo dot com

Description:

the compiler ought to bypass exceptions in try blocks, and allow a
catch block to catch the exception at runtime. in other words, try
blocks should turn compile-time errors to run-time errors. try blocks
shouldn't depend on the throw keyword before throwing exceptions, errors
in try blocks should automatically cause exceptions to be thrown.
otherwise the current Exception class is only as good as this statement
if(class_exists(Book)){//main code} else{//warning code} for the code
in my example.


Reproduce code:
---
?php
 try{
  $err=new Book(); //class Book does not exist
  //more code
 }
 catch(Exception $e){
  print class does not exist;
  exit();
  // or throw another exception that ends the program
  //in another block.
} 
 

Expected result:

output:(should look like this)

 class does not exist


(python and java behave like this, i hope there will be some
 consistence in logic, among open source languages )

Actual result:
--
program does not compile,
error message: Fatal error (actually says Fatel error),
   class 'Book' not found on C://XXX





-- 
Edit this bug report at http://bugs.php.net/?id=41012edit=1


#41012 [Bgs-Opn]: exception handling

2007-04-06 Thread perching_eagle at yahoo dot com
 ID:   41012
 User updated by:  perching_eagle at yahoo dot com
 Reported By:  perching_eagle at yahoo dot com
-Status:   Bogus
+Status:   Open
 Bug Type: *Compile Issues
 Operating System: windows xp
 PHP Version:  5.2.1
 New Comment:

why is not a bug?
this is an abnormal behavior, that restricts how you use the exception
class. if the try block can't force an erroreneous code to compile,
why do you have the try keyword anyway? the throw keyword could be
used outside a try block and also in a catch block or anywhere else
in the program. in a nutshell, the try keyword has no function at all
in php, if it does, what is it?

the documentation at php.net does not explain the function of the try
keyword in php.


Previous Comments:


[2007-04-06 18:55:16] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.



[2007-04-06 18:43:25] perching_eagle at yahoo dot com

Description:

the compiler ought to bypass exceptions in try blocks, and allow a
catch block to catch the exception at runtime. in other words, try
blocks should turn compile-time errors to run-time errors. try blocks
shouldn't depend on the throw keyword before throwing exceptions, errors
in try blocks should automatically cause exceptions to be thrown.
otherwise the current Exception class is only as good as this statement
if(class_exists(Book)){//main code} else{//warning code} for the code
in my example.


Reproduce code:
---
?php
 try{
  $err=new Book(); //class Book does not exist
  //more code
 }
 catch(Exception $e){
  print class does not exist;
  exit();
  // or throw another exception that ends the program
  //in another block.
} 
 

Expected result:

output:(should look like this)

 class does not exist


(python and java behave like this, i hope there will be some
 consistence in logic, among open source languages )

Actual result:
--
program does not compile,
error message: Fatal error (actually says Fatel error),
   class 'Book' not found on C://XXX





-- 
Edit this bug report at http://bugs.php.net/?id=41012edit=1