Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Improve Exception handlers #6430

Merged
merged 17 commits into from
May 20, 2024
Merged

Conversation

montezdesousa
Copy link
Contributor

@montezdesousa montezdesousa commented May 17, 2024

  1. Why?

    • Errors return by API are not consistent.
  2. What?

  • API errors
Status code Exception Detail Description
400 OpenBBError or child of OpenBBError Custom message. Use this to explicitly raise custom exceptions, like EmptyDataError.
422 ValidationError Pydantic errors dict message. Automatically raised to inform the user about query validation errors. ValidationErrors outside of the query are treated as 500 by default.
500 Any exception not covered above, eg ValueError, ZeroDivisionError Unexpected error. Unexpected exceptions, most likely a bug.
  • Python errors are similar but parse the detail in a readable format for both Python and CLI users
  1. Impact

    • API errors and Python errors
  2. Testing Done:

  • API examples
Screenshot 2024-05-17 at 16 09 20
  • Python equivalent
from openbb import obb
obb.equity.price.historical(symbol="milj", provider="fmp", interval="1d", start_date="2024-05-15")
obb.equity.price.historical(symbol="aapl", provider="XYZ", interval="1d", start_date="2024-05-15")
obb.equity.price.historical(symbol="aapl", provider="fmp", interval="1D", start_date="2024-05-15")

@github-actions github-actions bot added enhancement Enhancement platform OpenBB Platform v4 PRs for v4 labels May 17, 2024
@montezdesousa montezdesousa changed the title [Feature] Improve error handlers [Feature] Improve Exception handlers May 17, 2024
@github-actions github-actions bot added the excel label May 19, 2024
@montezdesousa montezdesousa marked this pull request as ready for review May 19, 2024 13:07
@IgorWounds IgorWounds added this pull request to the merge queue May 20, 2024
Merged via the queue into develop with commit be75bfe May 20, 2024
9 checks passed
@montezdesousa montezdesousa deleted the feature/error-handling branch May 20, 2024 08:36
@@ -538,6 +539,16 @@ As the OpenBB Platform has its own standardization framework and the data fetche
2. Extract - `extract_data(query: ExampleQueryParams,credentials: Optional[Dict[str, str]],**kwargs: Any,) -> Dict`: makes the request to the API endpoint and returns the raw data. Given the transformed query parameters, the credentials and any other extra arguments, this method should return the raw data as a dictionary.
3. Transform - `transform_data(query: ExampleQueryParams, data: Dict, **kwargs: Any) -> List[ExampleHistoricalData]`: transforms the raw data into the defined data model. Given the transformed query parameters (might be useful for some filtering), the raw data and any other extra arguments, this method should return the transformed data as a list of [`Data`](openbb_platform/platform/provider/openbb_core/provider/abstract/data.py) children.

#### Errors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should go to the docs website.
We should consider deprecate this document and just point potential contributors to the website instead.

cc @IgorWounds @montezdesousa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement excel platform OpenBB Platform v4 PRs for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants