Ë
    LµCjô	  ã                   ó   — d Z ddlmZmZ  G d„ de«      Z G d„ de«      Z G d„ de«      Z G d	„ d
e«      Z G d„ de«      Z	 G d„ de«      Z
 G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)uo  
Custom exception hierarchy.

Why this matters in production: a raw Python exception (KeyError,
ValueError, AttributeError from deep inside a model) should NEVER reach
the client directly. It might leak file paths, internal variable names,
or stack traces â€” that's an information disclosure risk, and it's also
just a bad client experience.

Every exception here carries:
- a client-safe `message` (shown to the user)
- an internal `detail` (logged, never returned)
- an HTTP status code
- an error `code` (machine-readable, e.g. "MODEL_INFERENCE_FAILED") so
  the frontend can branch on it without parsing message text.
é    )ÚAnyÚOptionalc            
       ój   ‡ — e Zd ZU dZdZeed<   dZeed<   	 	 d
dede	e   de	e
eef      fˆ fd	„Zˆ xZS )ÚAppExceptionz1Base class for all application-raised exceptions.éô  Ústatus_codeÚINTERNAL_ERRORÚ
error_codeÚmessageÚdetailÚextrac                 ó^   •— || _         |xs || _        |xs i | _        t        ‰| �  |«       y )N)r   r   r   ÚsuperÚ__init__)Úselfr   r   r   Ú	__class__s       €ú@C:\Crop_Prediction\Backend\crop-ai-system\app\core\exceptions.pyr   zAppException.__init__   s0   ø€ ð ˆŒØÒ' ˆŒØ’[˜bˆŒ
Ü‰Ñ˜Õ!ó    )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚintÚ__annotations__r
   Ústrr   Údictr   r   Ú__classcell__)r   s   @r   r   r      sY   ø… Ù;à€K�ÓØ&€J�Ó&ð
 !%Ø*.ñ		"àð	"ð ˜‘ð	"ð ˜˜S #˜X™Ñ'÷		"ñ 	"r   r   c                   ó   — e Zd ZdZdZy)ÚValidationFailedErrori¦  ÚVALIDATION_FAILEDN©r   r   r   r   r
   © r   r   r   r   '   s   „ Ø€KØ$�Jr   r   c                   ó   — e Zd ZdZdZy)ÚUnsupportedCropErroré�  ÚUNSUPPORTED_CROPNr!   r"   r   r   r$   r$   ,   s   „ Ø€KØ#�Jr   r$   c                   ó   — e Zd ZdZdZy)ÚUnsupportedDistrictErrorr%   ÚUNSUPPORTED_DISTRICTNr!   r"   r   r   r(   r(   1   s   „ Ø€KØ'�Jr   r(   c                   ó   — e Zd ZdZdZdZy)ÚModelNotLoadedErrorzJRaised when a required model file is missing or failed to load at startup.é÷  ÚMODEL_NOT_LOADEDN©r   r   r   r   r   r
   r"   r   r   r+   r+   6   s   „ ÙTØ€KØ#�Jr   r+   c                   ó   — e Zd ZdZdZdZy)ÚModelInferenceErrorzARaised when a model runs but produces an invalid/unusable result.r   ÚMODEL_INFERENCE_FAILEDNr.   r"   r   r   r0   r0   <   s   „ ÙKØ€KØ)�Jr   r0   c                   ó   — e Zd ZdZdZdZy)ÚLLMServiceErrorz4Raised when the Claude API call fails after retries.iö  ÚLLM_SERVICE_UNAVAILABLENr.   r"   r   r   r3   r3   B   s   „ Ù>Ø€KØ*�Jr   r3   c                   ó   — e Zd ZdZdZdZy)ÚCacheServiceErrorzGRaised when Redis is unreachable. Should degrade gracefully, not crash.r,   ÚCACHE_UNAVAILABLENr.   r"   r   r   r6   r6   H   s   „ ÙQØ€KØ$�Jr   r6   c                   ó   — e Zd ZdZdZy)ÚTaskNotFoundErrori”  ÚTASK_NOT_FOUNDNr!   r"   r   r   r9   r9   N   s   „ Ø€KØ!�Jr   r9   c                   ó   — e Zd ZdZdZy)ÚTaskTimeoutErroriø  ÚTASK_TIMEOUTNr!   r"   r   r   r<   r<   S   s   „ Ø€KØ�Jr   r<   c                   ó   — e Zd ZdZdZy)ÚRateLimitExceededErrori­  ÚRATE_LIMIT_EXCEEDEDNr!   r"   r   r   r?   r?   X   s   „ Ø€KØ&�Jr   r?   c                   ó   — e Zd ZdZdZy)ÚAuthenticationErrori‘  ÚAUTHENTICATION_FAILEDNr!   r"   r   r   rB   rB   ]   s   „ Ø€KØ(�Jr   rB   N)r   Útypingr   r   Ú	Exceptionr   r   r$   r(   r+   r0   r3   r6   r9   r<   r?   rB   r"   r   r   ú<module>rF      sŸ   ðñ÷" !ô"�9ô "ô$%˜Lô %ô
$˜<ô $ô
(˜|ô (ô
$˜,ô $ô*˜,ô *ô+�lô +ô%˜ô %ô"˜ô "ô
 �|ô  ô
'˜\ô 'ô
)˜,õ )r   