Skip to content

Commit

Permalink
fix: replace NPE with ISE
Browse files Browse the repository at this point in the history
Throw IllegalStateException when entity data could not be fetched from WikiData
  • Loading branch information
VaiTon committed Dec 3, 2021
1 parent 2341b13 commit b8c0d5c
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -22,6 +22,6 @@ class WikidataRepository @Inject constructor(
*/
suspend fun getEntityData(entityId: String): JsonNode {
require(entityId[0] == 'Q') { "Entity ID should start with 'Q'. Got: $entityId" }
return wikidataAPI.getEntity(entityId)["entities"][entityId]
return wikidataAPI.getEntity(entityId)["entities"][entityId] ?: throw IllegalStateException("Could not load entity $entityId from WikiData.")
}
}

0 comments on commit b8c0d5c

Please sign in to comment.