Skip to content

PHPC-744: Improve error messages for invalid Decimal128 and ObjectID strings #383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BSON/Decimal128.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ zend_object_handlers php_phongo_handler_decimal128;
static bool php_phongo_decimal128_init(php_phongo_decimal128_t *intern, const char *value TSRMLS_DC)
{
if (!bson_decimal128_from_string(value, &intern->decimal)) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing decimal string: %s", value);
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing Decimal128 string: %s", value);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/BSON/ObjectID.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static bool php_phongo_objectid_init_from_hex_string(php_phongo_objectid_t *inte
return true;
}

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

efree(tid);
return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/bson/bson-decimal128-serialization_error-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ echo throws(function() {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Error parsing decimal string: INVALID
Error parsing Decimal128 string: INVALID
===DONE===
2 changes: 1 addition & 1 deletion tests/bson/bson-decimal128-set_state_error-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ echo throws(function() {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Error parsing decimal string: INVALID
Error parsing Decimal128 string: INVALID
===DONE===
4 changes: 2 additions & 2 deletions tests/bson/bson-objectid-serialization_error-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ echo throws(function() {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Invalid BSON ID provided
Error parsing ObjectID string: 0123456789abcdefghijklmn
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Invalid BSON ID provided
Error parsing ObjectID string: INVALID
===DONE===
4 changes: 2 additions & 2 deletions tests/bson/bson-objectid-set_state_error-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ echo throws(function() {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Invalid BSON ID provided
Error parsing ObjectID string: 0123456789abcdefghijklmn
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Invalid BSON ID provided
Error parsing ObjectID string: INVALID
===DONE===
4 changes: 2 additions & 2 deletions tests/bson/bson-objectid_error-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ echo throws(function() {
<?php exit(0); ?>
--EXPECT--
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Invalid BSON ID provided
Error parsing ObjectID string: 0123456789abcdefghijklmn
OK: Got MongoDB\Driver\Exception\InvalidArgumentException
Invalid BSON ID provided
Error parsing ObjectID string: INVALID
===DONE===