Error handling for the getExchangeRate function