Handle KeyError in Graph class constructor
This commit is contained in:
parent
13a91a2625
commit
1b4f0138d2
1 changed files with 6 additions and 3 deletions
|
|
@ -320,9 +320,12 @@ class Graph:
|
||||||
return cls(vertices, edges, flow_id)
|
return cls(vertices, edges, flow_id)
|
||||||
except KeyError as exc:
|
except KeyError as exc:
|
||||||
logger.exception(exc)
|
logger.exception(exc)
|
||||||
raise ValueError(
|
if "nodes" not in payload and "edges" not in payload:
|
||||||
f"Invalid payload. Expected keys 'nodes' and 'edges'. Found {list(payload.keys())}"
|
logger.exception(exc)
|
||||||
) from exc
|
raise ValueError(
|
||||||
|
f"Invalid payload. Expected keys 'nodes' and 'edges'. Found {list(payload.keys())}"
|
||||||
|
) from exc
|
||||||
|
raise ValueError(f"Error while creating graph from payload: {exc}") from exc
|
||||||
|
|
||||||
def __eq__(self, other: object) -> bool:
|
def __eq__(self, other: object) -> bool:
|
||||||
if not isinstance(other, Graph):
|
if not isinstance(other, Graph):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue