File size: 1,979 Bytes
bfcc872
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
"""
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",
]