From: Xinchen Hui Date: Fri, 3 Jul 2015 03:18:53 +0000 (+0800) Subject: Catch the specifical exception X-Git-Tag: php-7.1.0alpha3~25^2~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8f992c163eff2fc5ebf44d9a39599ed70463253;p=php Catch the specifical exception --- diff --git a/Zend/tests/bug69957.phpt b/Zend/tests/bug69957.phpt index 5aa0edab21..d8d3a6f1fc 100644 --- a/Zend/tests/bug69957.phpt +++ b/Zend/tests/bug69957.phpt @@ -7,7 +7,7 @@ try { $divisor = 0; $result = 1 / $divisor; var_dump($result); -} catch (Throwable $t){ +} catch (DivisionByZeroError $t){ echo "Variable div\n"; printf("Type: %s\n", get_class($t)); printf("Message: %s\n", $t->getMessage()); @@ -17,7 +17,7 @@ try { $divisor = 0; $result = 1 % $divisor; var_dump($result); -} catch (Throwable $t){ +} catch (DivisionByZeroError $t){ echo "\nVariable mod\n"; printf("Type: %s\n", get_class($t)); printf("Message: %s\n", $t->getMessage()); @@ -26,7 +26,7 @@ try { try { $result = 1 / 0; var_dump($result); -} catch (Throwable $t){ +} catch (DivisionByZeroError $t){ echo "\nLiteral div\n"; printf("Type: %s\n", get_class($t)); printf("Message: %s\n", $t->getMessage()); @@ -35,7 +35,7 @@ try { try { $result = 1 % 0; var_dump($result); -} catch (Throwable $t){ +} catch (DivisionByZeroError $t){ echo "\nLiteral mod\n"; printf("Type: %s\n", get_class($t)); printf("Message: %s\n", $t->getMessage()); @@ -44,7 +44,7 @@ try { try { $result = 1 / 0.0; var_dump($result); -} catch (Throwable $t){ +} catch (DivisionByZeroError $t){ echo "\nDouble div\n"; printf("Type: %s\n", get_class($t)); printf("Message: %s\n", $t->getMessage()); @@ -53,7 +53,7 @@ try { try { $result = 1 % 0.0; var_dump($result); -} catch (Throwable $t){ +} catch (DivisionByZeroError $t){ echo "\nDouble mod\n"; printf("Type: %s\n", get_class($t)); printf("Message: %s\n", $t->getMessage()); diff --git a/Zend/tests/compound_assign_with_numeric_strings.phpt b/Zend/tests/compound_assign_with_numeric_strings.phpt index fbfc1605ec..72c80b0afc 100644 --- a/Zend/tests/compound_assign_with_numeric_strings.phpt +++ b/Zend/tests/compound_assign_with_numeric_strings.phpt @@ -11,7 +11,7 @@ $n = "-1"; try { $n <<= $n; var_dump($n); -} catch (Throwable $e) { +} catch (ArithmeticError $e) { echo "\nException: " . $e->getMessage() . "\n"; } @@ -23,7 +23,7 @@ $n = "-1"; try { $n >>= $n; var_dump($n); -} catch (Throwable $e) { +} catch (ArithmeticError $e) { echo "\nException: " . $e->getMessage() . "\n"; } @@ -31,7 +31,7 @@ $n = "0"; try{ $n %= $n; var_dump($n); -} catch (Throwable $e) { +} catch (DivisionByZeroError $e) { echo "\nException: " . $e->getMessage() . "\n"; } diff --git a/Zend/tests/mod_001.phpt b/Zend/tests/mod_001.phpt index ff589e2fee..2c1ebc7cc2 100644 --- a/Zend/tests/mod_001.phpt +++ b/Zend/tests/mod_001.phpt @@ -9,7 +9,7 @@ $b = array(); try { $c = $a % $b; var_dump($c); -} catch (Throwable $e) { +} catch (DivisionByZeroError $e) { echo "Exception: " . $e->getMessage() . "\n"; } diff --git a/tests/lang/operators/bitwiseShiftLeft_basiclong_64bit.phpt b/tests/lang/operators/bitwiseShiftLeft_basiclong_64bit.phpt index 380beca219..99626da6f1 100644 --- a/tests/lang/operators/bitwiseShiftLeft_basiclong_64bit.phpt +++ b/tests/lang/operators/bitwiseShiftLeft_basiclong_64bit.phpt @@ -27,7 +27,7 @@ foreach ($longVals as $longVal) { echo "--- testing: $longVal << $otherVal ---\n"; try { var_dump($longVal<<$otherVal); - } catch (Throwable $e) { + } catch (ArithmeticError $e) { echo "Exception: " . $e->getMessage() . "\n"; } } @@ -38,7 +38,7 @@ foreach ($otherVals as $otherVal) { echo "--- testing: $otherVal << $longVal ---\n"; try { var_dump($otherVal<<$longVal); - } catch (Throwable $e) { + } catch (ArithmeticError $e) { echo "Exception: " . $e->getMessage() . "\n"; } } diff --git a/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt b/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt index 174d947445..d5888d837f 100644 --- a/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt +++ b/tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt @@ -19,7 +19,7 @@ foreach ($strVals as $strVal) { echo "--- testing: '$strVal' << '$otherVal' ---\n"; try { var_dump($strVal<<$otherVal); - } catch (Throwable $e) { + } catch (ArithmeticError $e) { echo "Exception: " . $e->getMessage() . "\n"; } } diff --git a/tests/lang/operators/bitwiseShiftRight_basiclong_64bit.phpt b/tests/lang/operators/bitwiseShiftRight_basiclong_64bit.phpt index c85c440312..65e7e826b8 100644 --- a/tests/lang/operators/bitwiseShiftRight_basiclong_64bit.phpt +++ b/tests/lang/operators/bitwiseShiftRight_basiclong_64bit.phpt @@ -27,7 +27,7 @@ foreach ($longVals as $longVal) { echo "--- testing: $longVal >> $otherVal ---\n"; try { var_dump($longVal>>$otherVal); - } catch (Throwable $e) { + } catch (ArithmeticError $e) { echo "Exception: " . $e->getMessage() . "\n"; } } @@ -38,7 +38,7 @@ foreach ($otherVals as $otherVal) { echo "--- testing: $otherVal >> $longVal ---\n"; try { var_dump($otherVal>>$longVal); - } catch (Throwable $e) { + } catch (ArithmeticError $e) { echo "Exception: " . $e->getMessage() . "\n"; } } diff --git a/tests/lang/operators/bitwiseShiftRight_variationStr.phpt b/tests/lang/operators/bitwiseShiftRight_variationStr.phpt index 1c3277acc8..a86d0cfddb 100644 --- a/tests/lang/operators/bitwiseShiftRight_variationStr.phpt +++ b/tests/lang/operators/bitwiseShiftRight_variationStr.phpt @@ -15,7 +15,7 @@ foreach ($strVals as $strVal) { echo "--- testing: '$strVal' >> '$otherVal' ---\n"; try { var_dump($strVal>>$otherVal); - } catch (Throwable $e) { + } catch (ArithmeticError $e) { echo "Exception: " . $e->getMessage() . "\n"; } } diff --git a/tests/lang/operators/modulus_basiclong_64bit.phpt b/tests/lang/operators/modulus_basiclong_64bit.phpt index c2db77c120..6806bd53a8 100644 --- a/tests/lang/operators/modulus_basiclong_64bit.phpt +++ b/tests/lang/operators/modulus_basiclong_64bit.phpt @@ -27,7 +27,7 @@ foreach ($longVals as $longVal) { echo "--- testing: $longVal % $otherVal ---\n"; try { var_dump($longVal%$otherVal); - } catch (Throwable $e) { + } catch (DivisionByZeroError $e) { echo "Exception: " . $e->getMessage() . "\n"; } } @@ -38,7 +38,7 @@ foreach ($otherVals as $otherVal) { echo "--- testing: $otherVal % $longVal ---\n"; try { var_dump($otherVal%$longVal); - } catch (Throwable $e) { + } catch (DivisionByZeroError $e) { echo "Exception: " . $e->getMessage() . "\n"; } } diff --git a/tests/lang/operators/modulus_variationStr.phpt b/tests/lang/operators/modulus_variationStr.phpt index 49487000b3..c647ecd380 100644 --- a/tests/lang/operators/modulus_variationStr.phpt +++ b/tests/lang/operators/modulus_variationStr.phpt @@ -15,7 +15,7 @@ foreach ($strVals as $strVal) { echo "--- testing: '$strVal' % '$otherVal' ---\n"; try { var_dump($strVal%$otherVal); - } catch (Throwable $e) { + } catch (DivisionByZeroError $e) { echo "Exception: " . $e->getMessage() . "\n"; } }