Made parsing error handling slightly more specific

This commit is contained in:
BLM 2015-07-14 15:12:20 -05:00
parent adbcd9b878
commit 2c8dd38166
1 changed files with 7 additions and 0 deletions

View File

@ -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);