Skip to content

Commit 5f334ce

Browse files
committed
Make error message more meaningful
We also put this code branch under test. git-svn-id: http://svn.php.net/repository/pecl/dbase/trunk@340795 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 120446c commit 5f334ce

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

dbase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static void php_dbase_put_record(INTERNAL_FUNCTION_PARAMETERS, int replace)
219219
num_fields = zend_hash_num_elements(fields);
220220

221221
if (num_fields != dbht->db_nfields) {
222-
php_error_docref(NULL, E_WARNING, "Wrong number of fields specified");
222+
php_error_docref(NULL, E_WARNING, "expected %d fields, but got %d", dbht->db_nfields, num_fields);
223223
RETURN_FALSE;
224224
}
225225

tests/dbase_add_record_error.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ try {
1616
} catch (TypeError $ex) {
1717
echo $ex->getMessage(), PHP_EOL;
1818
}
19+
20+
var_dump(dbase_add_record($db, []));
1921
?>
2022
===DONE===
21-
--EXPECT--
23+
--EXPECTF--
2224
Argument 2 passed to dbase_add_record() must be of the type array, string given
25+
26+
Warning: dbase_add_record(): expected 5 fields, but got 0 in %s on line %d
27+
bool(false)
2328
===DONE===
2429
--CLEAN--
2530
<?php

tests/dbase_replace_record_error.phpt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ try {
1616
} catch (TypeError $ex) {
1717
echo $ex->getMessage(), PHP_EOL;
1818
}
19+
20+
var_dump(dbase_replace_record($db, [], 1));
1921
?>
2022
===DONE===
21-
--EXPECT--
23+
--EXPECTF--
2224
Argument 2 passed to dbase_replace_record() must be of the type array, string given
25+
26+
Warning: dbase_replace_record(): expected 5 fields, but got 0 in %s on line %d
27+
bool(false)
2328
===DONE===
2429
--CLEAN--
2530
<?php

0 commit comments

Comments
 (0)