mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2025-09-14 09:19:40 +00:00
add SkyvernHTTPException base exception to automate known error handling in agent service (#317)
This commit is contained in:
parent
164a4da03a
commit
c17b4ed287
2 changed files with 27 additions and 10 deletions
|
@ -1,9 +1,18 @@
|
|||
from fastapi import status
|
||||
|
||||
|
||||
class SkyvernException(Exception):
|
||||
def __init__(self, message: str | None = None):
|
||||
self.message = message
|
||||
super().__init__(message)
|
||||
|
||||
|
||||
class SkyvernHTTPException(SkyvernException):
|
||||
def __init__(self, message: str | None = None, status_code: int = status.HTTP_400_BAD_REQUEST):
|
||||
self.status_code = status_code
|
||||
super().__init__(message)
|
||||
|
||||
|
||||
class InvalidOpenAIResponseFormat(SkyvernException):
|
||||
def __init__(self, message: str | None = None):
|
||||
super().__init__(f"Invalid response format: {message}")
|
||||
|
@ -22,9 +31,9 @@ class ProxyLocationNotSupportedError(SkyvernException):
|
|||
super().__init__(f"Unknown proxy location: {proxy_location}")
|
||||
|
||||
|
||||
class TaskNotFound(SkyvernException):
|
||||
class TaskNotFound(SkyvernHTTPException):
|
||||
def __init__(self, task_id: str | None = None):
|
||||
super().__init__(f"Task {task_id} not found")
|
||||
super().__init__(f"Task {task_id} not found", status_code=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
|
||||
class ScriptNotFound(SkyvernException):
|
||||
|
@ -97,9 +106,9 @@ class UnknownBlockType(SkyvernException):
|
|||
super().__init__(f"Unknown block type {block_type}")
|
||||
|
||||
|
||||
class WorkflowNotFound(SkyvernException):
|
||||
class WorkflowNotFound(SkyvernHTTPException):
|
||||
def __init__(self, workflow_id: str) -> None:
|
||||
super().__init__(f"Workflow {workflow_id} not found")
|
||||
super().__init__(f"Workflow {workflow_id} not found", status_code=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
|
||||
class WorkflowRunNotFound(SkyvernException):
|
||||
|
@ -119,9 +128,9 @@ class MissingValueForParameter(SkyvernException):
|
|||
)
|
||||
|
||||
|
||||
class WorkflowParameterNotFound(SkyvernException):
|
||||
class WorkflowParameterNotFound(SkyvernHTTPException):
|
||||
def __init__(self, workflow_parameter_id: str) -> None:
|
||||
super().__init__(f"Workflow parameter {workflow_parameter_id} not found")
|
||||
super().__init__(f"Workflow parameter {workflow_parameter_id} not found", status_code=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
|
||||
class FailedToNavigateToUrl(SkyvernException):
|
||||
|
@ -163,14 +172,17 @@ class BrowserStateMissingPage(SkyvernException):
|
|||
super().__init__("BrowserState is missing the main page")
|
||||
|
||||
|
||||
class OrganizationNotFound(SkyvernException):
|
||||
class OrganizationNotFound(SkyvernHTTPException):
|
||||
def __init__(self, organization_id: str) -> None:
|
||||
super().__init__(f"Organization {organization_id} not found")
|
||||
super().__init__(f"Organization {organization_id} not found", status_code=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
|
||||
class StepNotFound(SkyvernException):
|
||||
class StepNotFound(SkyvernHTTPException):
|
||||
def __init__(self, organization_id: str, task_id: str, step_id: str | None = None) -> None:
|
||||
super().__init__(f"Step {step_id or 'latest'} not found. organization_id={organization_id} task_id={task_id}")
|
||||
super().__init__(
|
||||
f"Step {step_id or 'latest'} not found. organization_id={organization_id} task_id={task_id}",
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
)
|
||||
|
||||
|
||||
class FailedToTakeScreenshot(SkyvernException):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue