Error Bubbling: Implement machine-readable rich error objects for CRUD operations

This commit is contained in:
Scott Idem
2026-01-19 17:01:58 -05:00
parent 19e64135ca
commit eeb19647f5
4 changed files with 70 additions and 13 deletions

View File

@@ -432,8 +432,9 @@ async def post_obj(
return mk_resp(data=resp_data, response=response)
return mk_resp(data={"obj_id": new_obj_id, "obj_id_random": new_obj_id_random}, response=response)
else:
# Standardized rich error bubbling
db_err = format_db_error(get_last_sql_error())
return mk_resp(data=False, status_code=400, response=response, status_message="Failed to create object.", details=db_err)
return mk_resp(data=False, status_code=400, response=response, status_message="Failed to create object.", details=db_err.dict())
@router.patch('/{obj_type_l1}/{obj_id}', response_model=Resp_Body_Base)
@@ -494,8 +495,9 @@ async def patch_obj(
return mk_resp(data=resp_data, response=response)
return mk_resp(data=True, response=response, status_message="Object updated successfully.")
else:
# Standardized rich error bubbling
db_err = format_db_error(get_last_sql_error())
return mk_resp(data=False, status_code=400, response=response, status_message="Failed to update object.", details=db_err)
return mk_resp(data=False, status_code=400, response=response, status_message="Failed to update object.", details=db_err.dict())
@router.delete('/{obj_type_l1}/{obj_id}', response_model=Resp_Body_Base)