Skip to content

Commit e8f992c

Browse files
committed
Catch the specifical exception
1 parent 21029da commit e8f992c

9 files changed

+19
-19
lines changed

Zend/tests/bug69957.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ try {
77
$divisor = 0;
88
$result = 1 / $divisor;
99
var_dump($result);
10-
} catch (Throwable $t){
10+
} catch (DivisionByZeroError $t){
1111
echo "Variable div\n";
1212
printf("Type: %s\n", get_class($t));
1313
printf("Message: %s\n", $t->getMessage());
@@ -17,7 +17,7 @@ try {
1717
$divisor = 0;
1818
$result = 1 % $divisor;
1919
var_dump($result);
20-
} catch (Throwable $t){
20+
} catch (DivisionByZeroError $t){
2121
echo "\nVariable mod\n";
2222
printf("Type: %s\n", get_class($t));
2323
printf("Message: %s\n", $t->getMessage());
@@ -26,7 +26,7 @@ try {
2626
try {
2727
$result = 1 / 0;
2828
var_dump($result);
29-
} catch (Throwable $t){
29+
} catch (DivisionByZeroError $t){
3030
echo "\nLiteral div\n";
3131
printf("Type: %s\n", get_class($t));
3232
printf("Message: %s\n", $t->getMessage());
@@ -35,7 +35,7 @@ try {
3535
try {
3636
$result = 1 % 0;
3737
var_dump($result);
38-
} catch (Throwable $t){
38+
} catch (DivisionByZeroError $t){
3939
echo "\nLiteral mod\n";
4040
printf("Type: %s\n", get_class($t));
4141
printf("Message: %s\n", $t->getMessage());
@@ -44,7 +44,7 @@ try {
4444
try {
4545
$result = 1 / 0.0;
4646
var_dump($result);
47-
} catch (Throwable $t){
47+
} catch (DivisionByZeroError $t){
4848
echo "\nDouble div\n";
4949
printf("Type: %s\n", get_class($t));
5050
printf("Message: %s\n", $t->getMessage());
@@ -53,7 +53,7 @@ try {
5353
try {
5454
$result = 1 % 0.0;
5555
var_dump($result);
56-
} catch (Throwable $t){
56+
} catch (DivisionByZeroError $t){
5757
echo "\nDouble mod\n";
5858
printf("Type: %s\n", get_class($t));
5959
printf("Message: %s\n", $t->getMessage());

Zend/tests/compound_assign_with_numeric_strings.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $n = "-1";
1111
try {
1212
$n <<= $n;
1313
var_dump($n);
14-
} catch (Throwable $e) {
14+
} catch (ArithmeticError $e) {
1515
echo "\nException: " . $e->getMessage() . "\n";
1616
}
1717

@@ -23,15 +23,15 @@ $n = "-1";
2323
try {
2424
$n >>= $n;
2525
var_dump($n);
26-
} catch (Throwable $e) {
26+
} catch (ArithmeticError $e) {
2727
echo "\nException: " . $e->getMessage() . "\n";
2828
}
2929

3030
$n = "0";
3131
try{
3232
$n %= $n;
3333
var_dump($n);
34-
} catch (Throwable $e) {
34+
} catch (DivisionByZeroError $e) {
3535
echo "\nException: " . $e->getMessage() . "\n";
3636
}
3737

Zend/tests/mod_001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $b = array();
99
try {
1010
$c = $a % $b;
1111
var_dump($c);
12-
} catch (Throwable $e) {
12+
} catch (DivisionByZeroError $e) {
1313
echo "Exception: " . $e->getMessage() . "\n";
1414
}
1515

tests/lang/operators/bitwiseShiftLeft_basiclong_64bit.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ foreach ($longVals as $longVal) {
2727
echo "--- testing: $longVal << $otherVal ---\n";
2828
try {
2929
var_dump($longVal<<$otherVal);
30-
} catch (Throwable $e) {
30+
} catch (ArithmeticError $e) {
3131
echo "Exception: " . $e->getMessage() . "\n";
3232
}
3333
}
@@ -38,7 +38,7 @@ foreach ($otherVals as $otherVal) {
3838
echo "--- testing: $otherVal << $longVal ---\n";
3939
try {
4040
var_dump($otherVal<<$longVal);
41-
} catch (Throwable $e) {
41+
} catch (ArithmeticError $e) {
4242
echo "Exception: " . $e->getMessage() . "\n";
4343
}
4444
}

tests/lang/operators/bitwiseShiftLeft_variationStr_64bit.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ foreach ($strVals as $strVal) {
1919
echo "--- testing: '$strVal' << '$otherVal' ---\n";
2020
try {
2121
var_dump($strVal<<$otherVal);
22-
} catch (Throwable $e) {
22+
} catch (ArithmeticError $e) {
2323
echo "Exception: " . $e->getMessage() . "\n";
2424
}
2525
}

tests/lang/operators/bitwiseShiftRight_basiclong_64bit.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ foreach ($longVals as $longVal) {
2727
echo "--- testing: $longVal >> $otherVal ---\n";
2828
try {
2929
var_dump($longVal>>$otherVal);
30-
} catch (Throwable $e) {
30+
} catch (ArithmeticError $e) {
3131
echo "Exception: " . $e->getMessage() . "\n";
3232
}
3333
}
@@ -38,7 +38,7 @@ foreach ($otherVals as $otherVal) {
3838
echo "--- testing: $otherVal >> $longVal ---\n";
3939
try {
4040
var_dump($otherVal>>$longVal);
41-
} catch (Throwable $e) {
41+
} catch (ArithmeticError $e) {
4242
echo "Exception: " . $e->getMessage() . "\n";
4343
}
4444
}

tests/lang/operators/bitwiseShiftRight_variationStr.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ foreach ($strVals as $strVal) {
1515
echo "--- testing: '$strVal' >> '$otherVal' ---\n";
1616
try {
1717
var_dump($strVal>>$otherVal);
18-
} catch (Throwable $e) {
18+
} catch (ArithmeticError $e) {
1919
echo "Exception: " . $e->getMessage() . "\n";
2020
}
2121
}

tests/lang/operators/modulus_basiclong_64bit.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ foreach ($longVals as $longVal) {
2727
echo "--- testing: $longVal % $otherVal ---\n";
2828
try {
2929
var_dump($longVal%$otherVal);
30-
} catch (Throwable $e) {
30+
} catch (DivisionByZeroError $e) {
3131
echo "Exception: " . $e->getMessage() . "\n";
3232
}
3333
}
@@ -38,7 +38,7 @@ foreach ($otherVals as $otherVal) {
3838
echo "--- testing: $otherVal % $longVal ---\n";
3939
try {
4040
var_dump($otherVal%$longVal);
41-
} catch (Throwable $e) {
41+
} catch (DivisionByZeroError $e) {
4242
echo "Exception: " . $e->getMessage() . "\n";
4343
}
4444
}

tests/lang/operators/modulus_variationStr.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ foreach ($strVals as $strVal) {
1515
echo "--- testing: '$strVal' % '$otherVal' ---\n";
1616
try {
1717
var_dump($strVal%$otherVal);
18-
} catch (Throwable $e) {
18+
} catch (DivisionByZeroError $e) {
1919
echo "Exception: " . $e->getMessage() . "\n";
2020
}
2121
}

0 commit comments

Comments
 (0)