diff --git a/hyperglass/configuration/models/messages.py b/hyperglass/configuration/models/messages.py index 02b109c..01f5218 100644 --- a/hyperglass/configuration/models/messages.py +++ b/hyperglass/configuration/models/messages.py @@ -79,6 +79,11 @@ class Messages(HyperglassModel): title="No Output", description="Displayed when hyperglass can connect to a device and execute a query, but the response is empty.", ) + parsing_error: StrictStr = Field( + "An error occurred while parsing the query output.", + title="Parsing Error", + description="Displayed when hyperglass can connect to a device and execute a query, but the response cannot be parsed.", + ) class Config: """Pydantic model configuration.""" diff --git a/hyperglass/execution/execute.py b/hyperglass/execution/execute.py index 95d0ba3..2224b5d 100644 --- a/hyperglass/execution/execute.py +++ b/hyperglass/execution/execute.py @@ -82,6 +82,7 @@ class Connect: """ log.debug(f"Pre-parsed responses:\n{output}") parsed = () + response = None if not self.device.structured_output: for coro in parsers: for response in output: @@ -96,6 +97,8 @@ class Connect: func = nos_parsers[self.device.nos][self.query_type] response = func(output) log.debug(f"Post-parsed responses:\n{response}") + if response is None: + raise ResponseEmpty(params.messages.parsing_error) return response async def scrape_proxied(self):