Made parsing error handling slightly more specific
This commit is contained in:
parent
adbcd9b878
commit
2c8dd38166
|
@ -51,8 +51,10 @@ extern "C" {
|
||||||
PhoneNumber *number;
|
PhoneNumber *number;
|
||||||
|
|
||||||
number = (PhoneNumber*)palloc0(sizeof(PhoneNumber));
|
number = (PhoneNumber*)palloc0(sizeof(PhoneNumber));
|
||||||
|
//TODO: can this be removed? (palloc normally handles this, right?)
|
||||||
if(number == nullptr) {
|
if(number == nullptr) {
|
||||||
reportOutOfMemory();
|
reportOutOfMemory();
|
||||||
|
PG_RETURN_NULL();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -64,6 +66,11 @@ extern "C" {
|
||||||
//The number was parsed correctly; return it.
|
//The number was parsed correctly; return it.
|
||||||
PG_RETURN_POINTER(number);
|
PG_RETURN_POINTER(number);
|
||||||
break;
|
break;
|
||||||
|
case PNU::NOT_A_NUMBER:
|
||||||
|
reportParsingError(str, "String does not appear to contain a phone number.");
|
||||||
|
case PNU::INVALID_COUNTRY_CODE_ERROR:
|
||||||
|
reportParsingError(str, "Invalid country code");
|
||||||
|
//TODO: handle more error cases specifically.
|
||||||
default:
|
default:
|
||||||
//We have some generic parsing error.
|
//We have some generic parsing error.
|
||||||
reportParsingError(str);
|
reportParsingError(str);
|
||||||
|
|
Loading…
Reference in New Issue