zabgrab.errors

Exceptions shared by all layers.

Every error that is expected to reach the user derives from ZabgrabError. These errors carry a human-readable message and, where possible, a hint telling the user how to fix the problem. The CLI renders them without a traceback (unless --debug is given) and exits with ZabgrabError.exit_code.

zabgrab.errors.EXIT_ERROR

Exit code for errors (command line mistakes exit with click’s 2).

Type:

int

zabgrab.errors.EXIT_PARTIAL

Exit code when some items couldn’t be fetched but others were.

Type:

int

zabgrab.errors.EXIT_INTERRUPTED

Exit code when the user cancelled (as for Ctrl-C).

Type:

int

Exceptions

AuthenticationFailed(message, *[, code, ...])

The server rejected the credentials.

Cancelled()

The user cancelled at a prompt.

ConfigError(message, *[, path, details, hint])

A config file could not be read, parsed or validated.

ConnectionFailed(message, *[, details, hint])

The server couldn't be reached, or didn't respond like a Zabbix server.

InputRequired(question, *, fix)

Input was needed from the user but the session is not interactive.

Redirected(message, *, target[, hint])

The API endpoint redirected elsewhere (e.g. HTTP to HTTPS).

UnsupportedServer(message, *[, details, hint])

The server runs a Zabbix version zabgrab doesn't support.

ZabbixAPIError(message, *[, code, data, hint])

The Zabbix API returned an error.

ZabbixError(message, *[, details, hint])

A problem talking to a Zabbix server.

ZabgrabError(message, *[, details, hint])

An error with a message intended for the user.

exception zabgrab.errors.ZabgrabError(message, *, details=(), hint=None)[source]

Bases: Exception

An error with a message intended for the user.

Parameters:
  • message (str) – What went wrong, as a sentence.

  • details (sequence of str, optional) – Further lines, e.g. one per problem found.

  • hint (str, optional) – How to fix it.

Return type:

None

exit_code

The exit code to use when this error ends the program.

Type:

int

reported

Set when the error has already been shown to the user, so the CLI exits without repeating it.

Type:

bool

exception zabgrab.errors.ConfigError(message, *, path=None, details=(), hint=None)[source]

Bases: ZabgrabError

A config file could not be read, parsed or validated.

Parameters:
Return type:

None

exception zabgrab.errors.InputRequired(question, *, fix)[source]

Bases: ZabgrabError

Input was needed from the user but the session is not interactive.

Parameters:
  • question (str) – What would have been asked.

  • fix (str) – How to supply the input without a prompt, e.g. a flag to add or a config snippet.

Return type:

None

exception zabgrab.errors.Cancelled[source]

Bases: ZabgrabError

The user cancelled at a prompt.

Return type:

None

exception zabgrab.errors.ZabbixError(message, *, details=(), hint=None)[source]

Bases: ZabgrabError

A problem talking to a Zabbix server.

Parameters:
  • message (str)

  • details (Sequence[str])

  • hint (str | None)

Return type:

None

exception zabgrab.errors.ConnectionFailed(message, *, details=(), hint=None)[source]

Bases: ZabbixError

The server couldn’t be reached, or didn’t respond like a Zabbix server.

Parameters:
  • message (str)

  • details (Sequence[str])

  • hint (str | None)

Return type:

None

exception zabgrab.errors.Redirected(message, *, target, hint=None)[source]

Bases: ConnectionFailed

The API endpoint redirected elsewhere (e.g. HTTP to HTTPS).

Parameters:
Return type:

None

exception zabgrab.errors.ZabbixAPIError(message, *, code=None, data='', hint=None)[source]

Bases: ZabbixError

The Zabbix API returned an error.

Parameters:
  • message (str) – As for ZabgrabError.

  • hint (str | None) – As for ZabgrabError.

  • code (int, optional) – The JSON-RPC error code.

  • data (str, optional) – The error’s details from the server.

Return type:

None

exception zabgrab.errors.AuthenticationFailed(message, *, code=None, data='', hint=None)[source]

Bases: ZabbixAPIError

The server rejected the credentials.

Parameters:
  • message (str)

  • code (int | None)

  • data (str)

  • hint (str | None)

Return type:

None

exception zabgrab.errors.UnsupportedServer(message, *, details=(), hint=None)[source]

Bases: ZabbixError

The server runs a Zabbix version zabgrab doesn’t support.

Parameters:
  • message (str)

  • details (Sequence[str])

  • hint (str | None)

Return type:

None