Error handling
This page looks at different types of errors that can occur when using the FanPoints SDK.
Missing configuration
If the client is not properly configured, an Exception
is raised with the details on why the configuration is faulty.
Request errors
Whenever an operation fails due to invalid inputs (like an invalid user id or an invalid price), a ResponseError
is raised. The ResponseError
object contains an attribute error_codes
with the specific errors raised:
import asynciofrom fanpoints_python import FanpointsClient, ResponseErrorfrom fanpoints_python.types import Currency
client = FanpointsClient( partner_id='<your partner id>', client_id='<your client id>', secret='<your client secret>',)
async def run(): try: await client.conversion.get_price_in_fan_points( price=-10.0, # negative price currency=Currency.chf, ) except ResponseError as e: print(e.error_codes) # ['invalid_reward_amount_error']
asyncio.run(run())
If there is another type of error, an Exception
or a GraphQLClientGraphQLMultiError
, potentially with more details, is raised.