Expose pincode resolver errors in extraction
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
All checks were successful
build-and-deploy / build-deploy (push) Successful in 33s
This commit is contained in:
@@ -20,7 +20,7 @@ class DataGovPincodeClient(
|
||||
private val logger = LoggerFactory.getLogger(DataGovPincodeClient::class.java)
|
||||
|
||||
fun resolve(pinCode: String): PincodeLookupResult {
|
||||
if (apiKey.isBlank()) return PincodeLookupResult(null, null, "NO_API_KEY", "data.gov.in")
|
||||
if (apiKey.isBlank()) return PincodeLookupResult(null, null, "NO_API_KEY", "data.gov.in", "Missing API key")
|
||||
return try {
|
||||
val url = UriComponentsBuilder.fromUriString(baseUrl)
|
||||
.queryParam("api-key", apiKey)
|
||||
@@ -34,7 +34,7 @@ class DataGovPincodeClient(
|
||||
PincodeLookupResult(resolved, body, status, "data.gov.in")
|
||||
} catch (ex: Exception) {
|
||||
logger.warn("Data.gov.in lookup failed: {}", ex.message)
|
||||
PincodeLookupResult(null, null, "ERROR", "data.gov.in")
|
||||
PincodeLookupResult(null, null, "ERROR", "data.gov.in", ex.message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -437,15 +437,18 @@ class DocumentExtractionService(
|
||||
results["geoPrimarySource"] = primary.source
|
||||
primary.status?.let { results["geoPrimaryStatus"] = it }
|
||||
primary.rawResponse?.let { results["geoPrimaryResponse"] = it.take(4000) }
|
||||
primary.errorMessage?.let { results["geoPrimaryError"] = it.take(300) }
|
||||
resolvedResult.secondary?.let { secondary ->
|
||||
results["geoSecondarySource"] = secondary.source
|
||||
secondary.status?.let { results["geoSecondaryStatus"] = it }
|
||||
secondary.rawResponse?.let { results["geoSecondaryResponse"] = it.take(4000) }
|
||||
secondary.errorMessage?.let { results["geoSecondaryError"] = it.take(300) }
|
||||
}
|
||||
resolvedResult.tertiary?.let { tertiary ->
|
||||
results["geoTertiarySource"] = tertiary.source
|
||||
tertiary.status?.let { results["geoTertiaryStatus"] = it }
|
||||
tertiary.rawResponse?.let { results["geoTertiaryResponse"] = it.take(4000) }
|
||||
tertiary.errorMessage?.let { results["geoTertiaryError"] = it.take(300) }
|
||||
}
|
||||
val resolved = resolvedResult.resolved()?.resolvedCityState ?: return
|
||||
results["geoResolved"] = resolved
|
||||
|
||||
@@ -104,5 +104,6 @@ data class PincodeLookupResult(
|
||||
val resolvedCityState: String?,
|
||||
val rawResponse: String?,
|
||||
val status: String?,
|
||||
val source: String
|
||||
val source: String,
|
||||
val errorMessage: String? = null
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ class PostalPincodeClient(
|
||||
PincodeLookupResult(resolved, body, status, "postalpincode.in")
|
||||
} catch (ex: Exception) {
|
||||
logger.warn("Postalpincode lookup failed: {}", ex.message)
|
||||
PincodeLookupResult(null, null, "ERROR", "postalpincode.in")
|
||||
PincodeLookupResult(null, null, "ERROR", "postalpincode.in", ex.message)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user