Skip to content

Commit 5d2b5c2

Browse files
committed
PHPC-744: Improve error messages for invalid Decimal128 and ObjectID strings
1 parent 0fbe646 commit 5d2b5c2

7 files changed

+10
-10
lines changed

src/BSON/Decimal128.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ zend_object_handlers php_phongo_handler_decimal128;
5151
static bool php_phongo_decimal128_init(php_phongo_decimal128_t *intern, const char *value TSRMLS_DC)
5252
{
5353
if (!bson_decimal128_from_string(value, &intern->decimal)) {
54-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing decimal string: %s", value);
54+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing Decimal128 string: %s", value);
5555
return false;
5656
}
5757

src/BSON/ObjectID.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static bool php_phongo_objectid_init_from_hex_string(php_phongo_objectid_t *inte
7777
return true;
7878
}
7979

80-
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Invalid BSON ID provided");
80+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing ObjectID string: %s", oid);
8181

8282
efree(tid);
8383
return false;

tests/bson/bson-decimal128-serialization_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ echo throws(function() {
1616
<?php exit(0); ?>
1717
--EXPECT--
1818
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
19-
Error parsing decimal string: INVALID
19+
Error parsing Decimal128 string: INVALID
2020
===DONE===

tests/bson/bson-decimal128-set_state_error-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ echo throws(function() {
1616
<?php exit(0); ?>
1717
--EXPECT--
1818
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
19-
Error parsing decimal string: INVALID
19+
Error parsing Decimal128 string: INVALID
2020
===DONE===

tests/bson/bson-objectid-serialization_error-002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ echo throws(function() {
1818
<?php exit(0); ?>
1919
--EXPECT--
2020
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
21-
Invalid BSON ID provided
21+
Error parsing ObjectID string: 0123456789abcdefghijklmn
2222
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
23-
Invalid BSON ID provided
23+
Error parsing ObjectID string: INVALID
2424
===DONE===

tests/bson/bson-objectid-set_state_error-002.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ echo throws(function() {
1818
<?php exit(0); ?>
1919
--EXPECT--
2020
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
21-
Invalid BSON ID provided
21+
Error parsing ObjectID string: 0123456789abcdefghijklmn
2222
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
23-
Invalid BSON ID provided
23+
Error parsing ObjectID string: INVALID
2424
===DONE===

tests/bson/bson-objectid_error-003.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ echo throws(function() {
1818
<?php exit(0); ?>
1919
--EXPECT--
2020
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
21-
Invalid BSON ID provided
21+
Error parsing ObjectID string: 0123456789abcdefghijklmn
2222
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
23-
Invalid BSON ID provided
23+
Error parsing ObjectID string: INVALID
2424
===DONE===

0 commit comments

Comments
 (0)