grant-radar / src /analyzer /utils /errors.py
Riley Coleman
feat: add PDF & supporting materials integration to context
bfcc872
Raw
History Blame Contribute Delete
1.98 kB
"""
Standardized exceptions for the Grant Analyzer system.
Exception Hierarchy:
GrantAnalyzerError (base)
β”œβ”€β”€ DataLoadError # File I/O, parsing
β”œβ”€β”€ ValidationError # Input validation
β”œβ”€β”€ SearchError # Index/search issues
β”œβ”€β”€ LLMError # API/LLM failures
└── ConfigError # Configuration problems
"""
class GrantAnalyzerError(Exception):
"""
Base exception for all analyzer errors.
All custom exceptions inherit from this so callers can catch
all analyzer-specific errors with a single except clause.
"""
pass
class DataLoadError(GrantAnalyzerError):
"""
Error loading or parsing grant/supporting data.
Examples:
- JSON file not found
- Malformed JSON
- Missing required fields
- Excel read failure
"""
pass
class ValidationError(GrantAnalyzerError):
"""
User input validation failure.
Examples:
- Invalid grant ID format
- Empty search query
- URL not in allowlist
- Negative funding amount
"""
pass
class SearchError(GrantAnalyzerError):
"""
Search or index operation failure.
Examples:
- Index file corrupt
- Index version mismatch
- Search timeout
- Too many results
"""
pass
class LLMError(GrantAnalyzerError):
"""
LLM API call failure.
Examples:
- API key invalid
- Rate limit exceeded
- Timeout
- Model not found
- Response parsing error
"""
pass
class ConfigError(GrantAnalyzerError):
"""
Configuration error.
Examples:
- Missing required env var
- Invalid provider name
- Conflicting settings
"""
pass
# Convenience re-exports
__all__ = [
"GrantAnalyzerError",
"DataLoadError",
"ValidationError",
"SearchError",
"LLMError",
"ConfigError",
]