feat: ClassifaiError class for Errors and logging#121
Draft
frayle-ons wants to merge 3 commits intomainfrom
Draft
feat: ClassifaiError class for Errors and logging#121frayle-ons wants to merge 3 commits intomainfrom
frayle-ons wants to merge 3 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ Summary
Package Level Error Handling
These changes add a custom error class,
ClassifaiErrorused to catch and handle internal package errors, avoiding throwing raw errors or third party error message in code.Additional subclasses of ClassifaiError are also introduced for specific workflows within the package code including:
ConfigurationErrorDataValidationErrorExternalServiceErrorVectorisationErrorIndexBuildErrorHookValidationErrorThe codebase for the Vectorisers, VectorStore and start_api functionality have also been updated to use these custom Error classes where needed.
Examples include:
FastAPI Level Error Handling
When running the fastapi restAPI server, it is not beneficial to return direct python error messaging to the endpoint in most cases. Instead, we can use custom exception handlers with FastAPI to handle errors. In these cases FastAPI allows us to map an error code to a specific HTML response and response code. Additionally, the FastAPI layer is still responsible for data validation using Pydantic model used to define the endpoint definitions.
📜 Changes Introduced
✅ Checklist
terraform fmt&terraform validate)🔍 How to Test