Error handling for synchronous API.