Skip to content

Exceptions

All Dolphin exceptions inherit from DolphinError.


DolphinError

Bases: Exception

Base exception for dolphin_desktop.

Source code in src\dolphin_desktop\_exceptions.py
class DolphinError(Exception):
    """Base exception for dolphin_desktop."""

ElementNotFoundError

Bases: DolphinError

Raised when an element cannot be found within the timeout.

Source code in src\dolphin_desktop\_exceptions.py
class ElementNotFoundError(DolphinError):
    """Raised when an element cannot be found within the timeout."""

WaitTimeoutError

Bases: DolphinError

Raised when a wait condition is not met within the allowed time.

Source code in src\dolphin_desktop\_exceptions.py
class WaitTimeoutError(DolphinError):
    """Raised when a wait condition is not met within the allowed time."""

ApplicationError

Bases: DolphinError

Raised when application launch or connection fails.

Source code in src\dolphin_desktop\_exceptions.py
class ApplicationError(DolphinError):
    """Raised when application launch or connection fails."""

WindowNotFoundError

Bases: DolphinError

Raised when a window cannot be found.

Source code in src\dolphin_desktop\_exceptions.py
class WindowNotFoundError(DolphinError):
    """Raised when a window cannot be found."""

AliasNotFoundError

Bases: DolphinError

Raised when an alias is not found in the Object Repository.

Source code in src\dolphin_desktop\_exceptions.py
class AliasNotFoundError(DolphinError):
    """Raised when an alias is not found in the Object Repository."""

Catching exceptions

from dolphin_desktop import DolphinError, ElementNotFoundError, WaitTimeoutError

# Catch any Dolphin error
try:
    win.get_by_title("Submit").click()
except DolphinError as e:
    print(f"Dolphin error: {e}")

# Catch element not found specifically
try:
    win.get_by_automation_id("btnSubmit").timeout(5).click()
except ElementNotFoundError:
    # Fall back to image matching
    from dolphin_desktop import ImageLocator
    ImageLocator("templates/submit.png").click()

# Catch wait timeout
try:
    win.get_by_title("Loading...").wait_until_hidden(timeout=30)
except WaitTimeoutError:
    raise AssertionError("Loading never finished")

Exception hierarchy

DolphinError
|-- ElementNotFoundError
|-- WaitTimeoutError
|-- ApplicationError
|-- WindowNotFoundError
`-- AliasNotFoundError