Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update content_templates_parser.py #657

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/update_error_msg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- Updated the error message for the content_templates parser to include the correct parser name and detailed error information.
7 changes: 3 additions & 4 deletions plugins/sub_plugins/cli_parser/content_templates_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"""

EXAMPLES = """
- name: "Run command and parse with native"
- name: "Run command and parse with content_templates"
ansible.utils.cli_parse:
command: "show bgp summary"
parser:
Expand All @@ -41,7 +41,7 @@


class CliParser(CliParserBase):
"""The native parser class
"""The content_templates parser class
Convert raw text to structured data using the resource module parser
"""

Expand Down Expand Up @@ -72,8 +72,7 @@ def parse(self, *_args, **kwargs):
try:
parser.PARSERS = template_obj
out = {"parsed": parser.parse()}
print(out)
return out
except Exception as exc:
msg = "Native parser returned an error while parsing. Error: {err}"
msg = "An error occurred during content_templates parsing. Error: {err}"
return {"errors": [msg.format(err=to_native(exc))]}
Loading