Handle exceptions in the entity API.