|
15 | 15 | from uvicorn.config import LOG_LEVELS |
16 | 16 | from uvicorn.importer import import_from_string |
17 | 17 |
|
18 | | -from unstructured_platform_plugins.etl_uvicorn.errors import wrap_error |
19 | 18 | from unstructured_platform_plugins.etl_uvicorn.otel import get_metric_provider, get_trace_provider |
20 | 19 | from unstructured_platform_plugins.etl_uvicorn.utils import ( |
21 | 20 | get_func, |
@@ -185,15 +184,16 @@ async def _stream_response(): |
185 | 184 | ) |
186 | 185 | except Exception as e: |
187 | 186 | logger.error(f"Failure streaming response: {e}", exc_info=True) |
188 | | - http_error = wrap_error(e) |
189 | 187 | yield ( |
190 | 188 | InvokeResponse( |
191 | 189 | usage=usage, |
192 | 190 | message_channels=message_channels, |
193 | 191 | filedata_meta=filedata_meta_model.model_validate( |
194 | 192 | filedata_meta.model_dump() |
195 | 193 | ), |
196 | | - status_code=http_error.status_code, |
| 194 | + status_code=e.status_code |
| 195 | + if hasattr(e, "status_code") |
| 196 | + else status.HTTP_500_INTERNAL_SERVER_ERROR, |
197 | 197 | status_code_text=f"[{e.__class__.__name__}] {e}", |
198 | 198 | ).model_dump_json() |
199 | 199 | + "\n" |
@@ -226,12 +226,13 @@ async def _stream_response(): |
226 | 226 | ) |
227 | 227 | except Exception as invoke_error: |
228 | 228 | logger.error(f"failed to invoke plugin: {invoke_error}", exc_info=True) |
229 | | - http_error = wrap_error(invoke_error) |
230 | 229 | return InvokeResponse( |
231 | 230 | usage=usage, |
232 | 231 | message_channels=message_channels, |
233 | 232 | filedata_meta=filedata_meta_model.model_validate(filedata_meta.model_dump()), |
234 | | - status_code=http_error.status_code, |
| 233 | + status_code=invoke_error.status_code |
| 234 | + if hasattr(invoke_error, "status_code") |
| 235 | + else status.HTTP_500_INTERNAL_SERVER_ERROR, |
235 | 236 | status_code_text=f"[{invoke_error.__class__.__name__}] {invoke_error}", |
236 | 237 | file_data=request_dict.get("file_data", None), |
237 | 238 | ) |
|
0 commit comments