Skip to content

Commit 57fcbc9

Browse files
committed
Promote warnings to exceptions in ext/pspell
1 parent 517c993 commit 57fcbc9

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

ext/pspell/pspell.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,16 @@ static void php_pspell_close_config(zend_resource *rsrc)
7676
#define PSPELL_FETCH_CONFIG do { \
7777
zval *res = zend_hash_index_find(&EG(regular_list), conf); \
7878
if (res == NULL || Z_RES_P(res)->type != le_pspell_config) { \
79-
php_error_docref(NULL, E_WARNING, ZEND_LONG_FMT " is not a PSPELL config index", conf); \
80-
RETURN_FALSE; \
79+
zend_throw_error(NULL, ZEND_LONG_FMT " is not a PSPELL config index", conf); \
80+
RETURN_THROWS(); \
8181
} \
8282
config = (PspellConfig *)Z_RES_P(res)->ptr; \
8383
} while (0)
8484

8585
#define PSPELL_FETCH_MANAGER do { \
8686
zval *res = zend_hash_index_find(&EG(regular_list), scin); \
8787
if (res == NULL || Z_RES_P(res)->type != le_pspell) { \
88-
php_error_docref(NULL, E_WARNING, ZEND_LONG_FMT " is not a PSPELL result index", scin); \
89-
RETURN_FALSE; \
88+
zend_throw_error(NULL, ZEND_LONG_FMT " is not a PSPELL result index", conf); \
9089
} \
9190
manager = (PspellManager *)Z_RES_P(res)->ptr; \
9291
} while (0);

ext/pspell/tests/003.phpt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ $p = pspell_new_config($cfg);
1515
var_dump(pspell_check($p, 'yy'));
1616

1717
$p2 = pspell_new_config($cfg2);
18-
var_dump(pspell_check($p2, 'yy'));
18+
try {
19+
pspell_check($p2, 'yy');
20+
} catch (Error $exception) {
21+
echo $exception->getMessage() . "\n";
22+
}
1923

2024
echo "---\n";
2125
var_dump(pspell_config_ignore($cfg, 2));
@@ -30,9 +34,7 @@ var_dump(pspell_config_ignore($cfg, PHP_INT_MAX));
3034
bool(false)
3135

3236
Warning: pspell_new_config(): PSPELL couldn't open the dictionary. reason: The encoding "b0rked" is not known. This could also mean that the file "%sb0rked.%s" could not be opened for reading or does not exist. in %s003.php on line 9
33-
34-
Warning: pspell_check(): 0 is not a PSPELL result index in %s003.php on line 10
35-
bool(false)
37+
pspell_check(): 0 is not a PSPELL result index
3638
---
3739
bool(true)
3840
bool(true)

0 commit comments

Comments
 (0)