Skip to content

Commit ffe3642

Browse files
committed
Prices: improve exceptions & logging
Tidy messages sent to logging.INFO Use logging's 'extra' argument to make YF log formatting programmatic. Reclassify some YF price-repair log messages, so that repairs (or repair fails) are level INFO.
1 parent 59178f4 commit ffe3642

File tree

3 files changed

+141
-129
lines changed

3 files changed

+141
-129
lines changed

yfinance/exceptions.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ class YFDataException(YFException):
77
pass
88

99

10-
class YFChartError(YFException):
11-
def __init__(self, ticker, description):
12-
self.ticker = ticker
13-
super().__init__(f"{self.ticker}: {description}")
14-
15-
1610
class YFNotImplementedError(NotImplementedError):
1711
def __init__(self, method_name):
1812
super().__init__(f"Have not implemented fetching '{method_name}' from Yahoo API")
@@ -27,19 +21,22 @@ def __init__(self, ticker, rationale):
2721

2822
class YFTzMissingError(YFTickerMissingError):
2923
def __init__(self, ticker):
30-
super().__init__(ticker, "No timezone found")
24+
super().__init__(ticker, "no timezone found")
3125

3226

3327
class YFPricesMissingError(YFTickerMissingError):
3428
def __init__(self, ticker, debug_info):
3529
self.debug_info = debug_info
36-
super().__init__(ticker, f"No price data found {debug_info}")
30+
if debug_info != '':
31+
super().__init__(ticker, f"no price data found {debug_info}")
32+
else:
33+
super().__init__(ticker, "no price data found")
3734

3835

3936
class YFEarningsDateMissing(YFTickerMissingError):
4037
# note that this does not get raised. Added in case of raising it in the future
4138
def __init__(self, ticker):
42-
super().__init__(ticker, "No earnings dates found")
39+
super().__init__(ticker, "no earnings dates found")
4340

4441

4542
class YFInvalidPeriodError(YFException):

0 commit comments

Comments
 (0)