diff options
author | Danglewood <85772166+deeleeramone@users.noreply.github.com> | 2024-06-06 07:58:31 -0700 |
---|---|---|
committer | Danglewood <85772166+deeleeramone@users.noreply.github.com> | 2024-06-06 07:58:31 -0700 |
commit | c229425dfad16ec7849057f54f827ccc90bb2d53 (patch) | |
tree | baa8dac6f4f868bc6e544fa850241505f31ea630 | |
parent | e0759fa2c685a2796908e4575abe48a3ccc83c14 (diff) |
review itemsfeature/corporate-bond-indices
-rw-r--r-- | openbb_platform/providers/fred/openbb_fred/models/bond_indices.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/openbb_platform/providers/fred/openbb_fred/models/bond_indices.py b/openbb_platform/providers/fred/openbb_fred/models/bond_indices.py index bc0ba8135a1..345004e7ff3 100644 --- a/openbb_platform/providers/fred/openbb_fred/models/bond_indices.py +++ b/openbb_platform/providers/fred/openbb_fred/models/bond_indices.py @@ -5,6 +5,7 @@ from typing import Any, Dict, List, Literal, Optional, Union from warnings import warn +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.bond_indices import ( @@ -417,12 +418,9 @@ class FredBondIndicesFetcher( values = params.copy() new_index = [] messages = [] - if "index" not in values: - values["index"] = "yield_curve" - if "category" not in values: - values["category"] = "us" - if "index_type" not in values: - values["index_type"] = "yield" + values.setdefault("index", "yield_curve") + values.setdefault("category", "us") + values.setdefault("index_type", "yield") is_yield_curve = False if "yield_curve" in values["index"]: values["category"] = "us" @@ -472,7 +470,7 @@ class FredBondIndicesFetcher( else: new_index.append(index) if not new_index: - raise ValueError( + raise OpenBBError( "No valid combinations of parameters were found." + f"\n{','.join(messages) if messages else ''}" ) @@ -500,7 +498,7 @@ class FredBondIndicesFetcher( ] symbols = [symbol for symbol in symbols if symbol] if not symbols: - raise ValueError( + raise OpenBBError( "Error mapping the provided choices to series ID." + f"\n{','.join(messages) if messages else ''}" ) |