Skip to content

errors

Every exception derives from NetvizError and from the closest built-in exception. All of them are also importable from the top-level package, for example nv.MixedSliceError.

Exception types raised by netviz_tools.

Every exception derives from NetvizError, and also from the closest built-in exception, so except ValueError keeps working for callers who do not want to depend on this module.

NetvizError

Bases: Exception

Base class for all errors raised by netviz_tools.

SchemaError

SchemaError(problems: Sequence[str])

Bases: NetvizError, ValueError

A DataFrame does not match the expected flow schema.

Parameters:

Name Type Description Default
problems Sequence[str]

One message per problem found. All problems are reported at once.

required

MixedSliceError

Bases: NetvizError, ValueError

Flows span several time periods or categories but no aggregation was requested.

MixedUnitError

Bases: NetvizError, ValueError

Flows measured in different units would be combined.

UnknownMetricError

Bases: NetvizError, ValueError

A metric or method name is not supported.

InsufficientDataError

Bases: NetvizError, ValueError

There is not enough data for the requested computation.

UnknownNameError

UnknownNameError(
    kind: str, name: object, suggestions: Sequence[str] = ()
)

Bases: NetvizError, LookupError

A name could not be found. Close matches are offered as suggestions.

Parameters:

Name Type Description Default
kind str

What was being looked up, for example "item" or "node".

required
name object

The name that was not found.

required
suggestions Sequence[str]

Close matches, best first. May be empty.

()

UnknownItemError

UnknownItemError(
    name: object, suggestions: Sequence[str] = ()
)

Bases: UnknownNameError

A FAOSTAT item (commodity) name or code is not in the catalogue.

UnknownNodeError

UnknownNodeError(
    name: object, suggestions: Sequence[str] = ()
)

Bases: UnknownNameError

A node (for trade data, a country) is not present in the flows.

StoreNotFoundError

Bases: NetvizError, FileNotFoundError

The local Parquet store has not been built yet.

SourceHashMismatchError

SourceHashMismatchError(
    path: str, expected: str, actual: str | None = None
)

Bases: NetvizError, ValueError

A downloaded or local source file does not match the pinned SHA-256.

Parameters:

Name Type Description Default
path str

The file that was checked.

required
expected str

The pinned SHA-256.

required
actual str | None

The SHA-256 of the file, if it was computed.

None