Spaces:
Running
Running
File size: 679 Bytes
c758204 0ecc315 c758204 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from nl2sql.errors.codes import ErrorCode
ERROR_MAP = {
ErrorCode.SAFETY_NON_SELECT: (422, False),
ErrorCode.SAFETY_MULTI_STATEMENT: (422, False),
ErrorCode.PLAN_NO_SUCH_TABLE: (422, False),
ErrorCode.PLAN_NO_SUCH_COLUMN: (422, False),
ErrorCode.PLAN_SYNTAX_ERROR: (422, False),
ErrorCode.DB_LOCKED: (503, True),
ErrorCode.DB_TIMEOUT: (503, True),
ErrorCode.EXECUTOR_COST_GUARDRAIL_BLOCKED: (422, False),
ErrorCode.LLM_TIMEOUT: (503, True),
ErrorCode.PIPELINE_CRASH: (500, False),
}
def map_error(code: ErrorCode | None) -> tuple[int, bool]:
if code is None:
return (500, False)
return ERROR_MAP.get(code, (500, False))
|