11# -*- coding: utf-8 -*-
22from typing import Optional
33
4+ class LocalError (Exception ):
5+ pass
6+
7+ class UnknownItemError (LocalError ):
8+ pass
9+
410# https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses
5- class SDKError (Exception ):
11+ class APIError (Exception ):
612 def __init__ (self , message : Optional [str ] = None ):
713 if message is None :
814 message = "Please check the SDK documentation at https://github.com/code-kern-ai/kern-python"
915 super ().__init__ (message )
1016
1117
1218# 401 Unauthorized
13- class UnauthorizedError (SDKError ):
19+ class UnauthorizedError (APIError ):
1420 pass
1521
1622
1723# 404 Not Found
18- class NotFoundError (SDKError ):
24+ class NotFoundError (APIError ):
1925 pass
2026
21- class UnknownProjectError (SDKError ):
27+ class UnknownProjectError (APIError ):
2228 def __init__ (self , project_id : str ):
2329 super ().__init__ (message = f"Could not find project '{ project_id } '. Please check your input." )
2430
2531
2632# 500 Server Error
27- class InternalServerError (SDKError ):
33+ class InternalServerError (APIError ):
2834 pass
2935
3036
@@ -48,8 +54,8 @@ def get_api_exception_class(
4854 status_code : int ,
4955 error_code : Optional [str ] = None ,
5056 error_message : Optional [str ] = None ,
51- ) -> SDKError :
52- exception_or_dict = RESPONSE_CODES_API_EXCEPTION_MAP .get (status_code , SDKError )
57+ ) -> APIError :
58+ exception_or_dict = RESPONSE_CODES_API_EXCEPTION_MAP .get (status_code , APIError )
5359 if isinstance (exception_or_dict , dict ):
5460 exception_class = exception_or_dict .get (error_code , exception_or_dict ["*" ])
5561 else :
0 commit comments