Skip to content

Exceptions

Base

ObsidianError

Bases: Exception

Base exception for all aiobsidian errors.

CLI exceptions

CLIError

Bases: ObsidianError

Base exception for Obsidian CLI errors.

BinaryNotFoundError(message)

Bases: CLIError

The Obsidian CLI binary could not be found.

Attributes:

Name Type Description
message

Description of the error.

Source code in src/aiobsidian/_exceptions.py
def __init__(self, message: str) -> None:
    self.message = message
    super().__init__(message)

CommandError(command, exit_code, stderr)

Bases: CLIError

A CLI command exited with a non-zero status.

Attributes:

Name Type Description
command

The CLI command that failed.

exit_code

Process exit code.

stderr

Standard error output.

Source code in src/aiobsidian/_exceptions.py
def __init__(self, command: str, exit_code: int, stderr: str) -> None:
    self.command = command
    self.exit_code = exit_code
    self.stderr = stderr
    super().__init__(
        f"Command {command!r} failed (exit_code={exit_code}): {stderr}"
    )

CLITimeoutError(command, timeout)

Bases: CLIError

A CLI command exceeded the timeout limit.

Attributes:

Name Type Description
command

The CLI command that timed out.

timeout

Timeout value in seconds.

Source code in src/aiobsidian/_exceptions.py
def __init__(self, command: str, timeout: float) -> None:
    self.command = command
    self.timeout = timeout
    super().__init__(f"Command {command!r} timed out after {timeout}s")

REST API exceptions

APIError(status_code, message, error_code=None)

Bases: ObsidianError

Error returned by the Obsidian REST API.

Attributes:

Name Type Description
status_code

HTTP status code of the response.

message

Error message from the API.

error_code

Optional numeric error code from the API.

Source code in src/aiobsidian/_exceptions.py
def __init__(
    self,
    status_code: int,
    message: str,
    error_code: int | None = None,
) -> None:
    self.status_code = status_code
    self.message = message
    self.error_code = error_code
    msg = f"[{status_code}] {message}"
    if error_code is not None:
        msg += f" (error_code={error_code})"
    super().__init__(msg)

AuthenticationError(status_code, message, error_code=None)

Bases: APIError

HTTP 401 Unauthorized — invalid or missing API key.

Source code in src/aiobsidian/_exceptions.py
def __init__(
    self,
    status_code: int,
    message: str,
    error_code: int | None = None,
) -> None:
    self.status_code = status_code
    self.message = message
    self.error_code = error_code
    msg = f"[{status_code}] {message}"
    if error_code is not None:
        msg += f" (error_code={error_code})"
    super().__init__(msg)

NotFoundError(status_code, message, error_code=None)

Bases: APIError

HTTP 404 Not Found — the requested resource does not exist.

Source code in src/aiobsidian/_exceptions.py
def __init__(
    self,
    status_code: int,
    message: str,
    error_code: int | None = None,
) -> None:
    self.status_code = status_code
    self.message = message
    self.error_code = error_code
    msg = f"[{status_code}] {message}"
    if error_code is not None:
        msg += f" (error_code={error_code})"
    super().__init__(msg)