diff options
author | montezdesousa <79287829+montezdesousa@users.noreply.github.com> | 2024-06-17 10:09:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-17 09:09:28 +0000 |
commit | 5ec2db7643864b6a08d844126314377d35d812cc (patch) | |
tree | 2eb3961f76b4c0e50f29e2a6c0deeddea392f562 | |
parent | c5e16684baab63ce93deeb7641169ae4d3a1cf4a (diff) |
[BugFix] Replace some base exceptions by OpenBBError (#6502)
* fix: replace base exceptions by openbberrors
* Update yield_curve.py
* fix typo
---------
Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
75 files changed, 263 insertions, 201 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0b0a2174e4d..651aae6c924 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: entry: codespell args: [ - "--ignore-words-list=VAI,MIS,shs,gard,te,commun,parana,ro,zar,vie,hel,jewl,zlot,ba,buil,coo,ether,hist,hsi,mape,navagation,operatio,pres,ser,yeld,shold,ist,varian,datas,ake,creat,statics,ket,toke,certi,buidl,ot,fo", + "--ignore-words=.codespell.ignore", "--quiet-level=2", "--skip=./**/tests/**,./**/test_*.py,.git,*.css,*.csv,*.html,*.ini,*.ipynb,*.js,*.json,*.lock,*.scss,*.txt,*.yaml,build/pyinstaller/*,./website/config.toml", "-x=.github/workflows/general-linting.yml" diff --git a/openbb_platform/providers/biztoc/openbb_biztoc/utils/helpers.py b/openbb_platform/providers/biztoc/openbb_biztoc/utils/helpers.py index 061271c8a5d..ffb5c2a5a8b 100644 --- a/openbb_platform/providers/biztoc/openbb_biztoc/utils/helpers.py +++ b/openbb_platform/providers/biztoc/openbb_biztoc/utils/helpers.py @@ -5,6 +5,7 @@ from typing import Dict, List, Literal import requests import requests_cache +from openbb_core.app.model.abstract.error import OpenBBError from openbb_core.app.utils import get_user_cache_directory # pylint: disable=C0325 @@ -115,10 +116,10 @@ def get_news( "tag": f"tag/{tag}", } if filter_ == "source" and source.lower() not in sources: - raise ValueError(f"{source} not a valid source. Valid sources: {sources}") + raise OpenBBError(f"{source} not a valid source. Valid sources: {sources}") if filter_ == "tag" and tag.lower().replace(" ", "") not in tags: - raise ValueError(f"{tag} not a valid tag. Valid tags: {tags}") + raise OpenBBError(f"{tag} not a valid tag. Valid tags: {tags}") url = ( f"https://biztoc.p.rapidapi.com/search?q={term}" @@ -127,7 +128,7 @@ def get_news( ) r = requests.get(url, headers=headers, timeout=5) if r.status_code != 200: - raise RuntimeError(f"HTTP error - > {r.text}") + raise OpenBBError(f"HTTP error - > {r.text}") try: results = r.json() diff --git a/openbb_platform/providers/cboe/openbb_cboe/models/futures_curve.py b/openbb_platform/providers/cboe/openbb_cboe/models/futures_curve.py index fee62fb339a..ce1a267f4df 100644 --- a/openbb_platform/providers/cboe/openbb_cboe/models/futures_curve.py +++ b/openbb_platform/providers/cboe/openbb_cboe/models/futures_curve.py @@ -4,6 +4,7 @@ from typing import Any, Dict, List, Optional from openbb_cboe.utils.helpers import get_settlement_prices +from openbb_core.app.model.abstract.error import OpenBBError from openbb_core.provider.abstract.fetcher import Fetcher from openbb_core.provider.standard_models.futures_curve import ( FuturesCurveData, @@ -52,7 +53,7 @@ class CboeFuturesCurveFetcher( raise EmptyDataError() if symbol not in FUTURES["product"].unique().tolist(): - raise RuntimeError( + raise OpenBBError( "The symbol, " f"{symbol}" ", is not valid. Chose from: " diff --git a/openbb_platform/providers/cboe/openbb_cboe/models/options_chains.py b/openbb_platform/providers/cboe/openbb_cboe/models/options_chains.py index ca049ee80a7..16735cc4b76 100644 --- a/openbb_platform/providers/cboe/openbb_cboe/models/options_chains.py +++ b/openbb_platform/providers/cboe/openbb_cboe/models/options_chains.py @@ -10,6 +10,7 @@ from openbb_cboe.utils.helpers import ( get_company_directory, get_index_directory, ) +from openbb_core.app.model.abstract.error import OpenBBError from openbb_core.provider.abstract.annotated_result import AnnotatedResult from openbb_core.provider.abstract.fetcher import Fetcher from openbb_core.provider.standard_models.options_chains import ( @@ -66,7 +67,7 @@ class CboeOptionsChainsFetcher( INDEXES = INDEXES.set_index("index_symbol") if symbol not in SYMBOLS.index: - raise RuntimeError(f"{symbol} was not found in the Cboe options directory.") + raise OpenBBError(f"{symbol} was not found in the Cboe options directory.") quotes_url = ( f"https://cdn.cboe.com/api/global/delayed_quotes/options/_{symbol}.json" diff --git a/openbb_platform/providers/ecb/openbb_ecb/models/currency_reference_rates.py b/openbb_platform/providers/ecb/openbb_ecb/models/currency_reference_rates.py index 3eea898ff3c..278e28677f3 100644 --- a/openbb_platform/p |