|
22 | 22 | PostProcessingError, |
23 | 23 | PreProcessingError, |
24 | 24 | RoboflowAPIConnectionError, |
| 25 | + RoboflowAPIForbiddenError, |
25 | 26 | RoboflowAPINotAuthorizedError, |
26 | 27 | RoboflowAPINotNotFoundError, |
27 | 28 | RoboflowAPITimeoutError, |
|
45 | 46 | OperationTypeNotRecognisedError, |
46 | 47 | ) |
47 | 48 | from inference.core.workflows.errors import ( |
| 49 | + ClientCausedStepExecutionError, |
48 | 50 | DynamicBlockError, |
49 | 51 | ExecutionGraphStructureError, |
50 | 52 | InvalidReferenceTargetError, |
@@ -187,6 +189,16 @@ def wrapped_route(*args, **kwargs): |
187 | 189 | "to learn how to retrieve one." |
188 | 190 | }, |
189 | 191 | ) |
| 192 | + except RoboflowAPIForbiddenError as error: |
| 193 | + logger.exception("%s: %s", type(error).__name__, error) |
| 194 | + resp = JSONResponse( |
| 195 | + status_code=403, |
| 196 | + content={ |
| 197 | + "message": "Unauthorized access to roboflow API - check API key and make sure the key is valid and " |
| 198 | + "have required scopes. Visit https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key " |
| 199 | + "to learn how to retrieve one." |
| 200 | + }, |
| 201 | + ) |
190 | 202 | except RoboflowAPINotNotFoundError as error: |
191 | 203 | logger.exception("%s: %s", type(error).__name__, error) |
192 | 204 | resp = JSONResponse( |
@@ -284,6 +296,24 @@ def wrapped_route(*args, **kwargs): |
284 | 296 | "message": "Timeout when attempting to connect to Roboflow API." |
285 | 297 | }, |
286 | 298 | ) |
| 299 | + except ClientCausedStepExecutionError as error: |
| 300 | + logger.exception("%s: %s", type(error).__name__, error) |
| 301 | + content = WorkflowErrorResponse( |
| 302 | + message=str(error.public_message), |
| 303 | + error_type=error.__class__.__name__, |
| 304 | + context=str(error.context), |
| 305 | + inner_error_type=str(error.inner_error_type), |
| 306 | + inner_error_message=str(error.inner_error), |
| 307 | + blocks_errors=[ |
| 308 | + WorkflowBlockError( |
| 309 | + block_id=error.block_id, |
| 310 | + ), |
| 311 | + ], |
| 312 | + ) |
| 313 | + resp = JSONResponse( |
| 314 | + status_code=error.status_code, |
| 315 | + content=content.model_dump(), |
| 316 | + ) |
287 | 317 | except StepExecutionError as error: |
288 | 318 | logger.exception("%s: %s", type(error).__name__, error) |
289 | 319 | content = WorkflowErrorResponse( |
@@ -462,6 +492,16 @@ async def wrapped_route(*args, **kwargs): |
462 | 492 | "to learn how to retrieve one." |
463 | 493 | }, |
464 | 494 | ) |
| 495 | + except RoboflowAPIForbiddenError as error: |
| 496 | + logger.exception("%s: %s", type(error).__name__, error) |
| 497 | + resp = JSONResponse( |
| 498 | + status_code=403, |
| 499 | + content={ |
| 500 | + "message": "Unauthorized access to roboflow API - check API key and make sure the key is valid and " |
| 501 | + "have required scopes. Visit https://docs.roboflow.com/api-reference/authentication#retrieve-an-api-key " |
| 502 | + "to learn how to retrieve one." |
| 503 | + }, |
| 504 | + ) |
465 | 505 | except RoboflowAPINotNotFoundError as error: |
466 | 506 | logger.exception("%s: %s", type(error).__name__, error) |
467 | 507 | resp = JSONResponse( |
@@ -559,6 +599,24 @@ async def wrapped_route(*args, **kwargs): |
559 | 599 | "message": "Timeout when attempting to connect to Roboflow API." |
560 | 600 | }, |
561 | 601 | ) |
| 602 | + except ClientCausedStepExecutionError as error: |
| 603 | + logger.exception("%s: %s", type(error).__name__, error) |
| 604 | + content = WorkflowErrorResponse( |
| 605 | + message=str(error.public_message), |
| 606 | + error_type=error.__class__.__name__, |
| 607 | + context=str(error.context), |
| 608 | + inner_error_type=str(error.inner_error_type), |
| 609 | + inner_error_message=str(error.inner_error), |
| 610 | + blocks_errors=[ |
| 611 | + WorkflowBlockError( |
| 612 | + block_id=error.block_id, |
| 613 | + ), |
| 614 | + ], |
| 615 | + ) |
| 616 | + resp = JSONResponse( |
| 617 | + status_code=error.status_code, |
| 618 | + content=content.model_dump(), |
| 619 | + ) |
562 | 620 | except StepExecutionError as error: |
563 | 621 | logger.exception("%s: %s", type(error).__name__, error) |
564 | 622 | content = WorkflowErrorResponse( |
|
0 commit comments