Skip to content

Commit

Permalink
Handle and show error during report generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Paweł authored and Felipe444 committed May 20, 2020
1 parent 1878ace commit a3adadd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 8 additions & 3 deletions assets/report-generator/generate_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
template = Template(template_file.read())

with open(sys.argv[2], 'w') as result:
result.write(template.render(
validationResults = dredd_response["validationResults"]
))
try:
result.write(template.render(
validationResults = dredd_response["validationResults"]
))
except:
result.write(template.render(
errorMessage = dredd_response
))

else:
print('''Script requires two arguments - first is path to validation result json file, second is path to output html file -
Expand Down
12 changes: 10 additions & 2 deletions assets/report-generator/report_template.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,17 @@
{% endfor %}
</ul>
{% else %}
There were no interactions
{% if (errorMessage is defined)%}
<h1 style="color:red"> Error </h2>
<h3> Status: {{ errorMessage.status }} </h3>
<h3> Message: </h3>
<h3> {{ errorMessage.message }} </h2>
<h3> Path: {{ errorMessage.path}} </h3>
{% else %}
There were no interactions
{% endif %}
{% endif %}
</div>

</body>
</html>
</html>

1 comment on commit a3adadd

@asr11-sys
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

below is my response generated from
​/environment-compatibility-report​/{serviceName}:{serviceVersion} endpoint , but generated report coming blank . Can you please help me on this

[
{
"consumerAndProvider": {
"consumerName": "kyc-consumer",
"consumerVersion": "1.0.1-SNAPSHOT",
"providerName": "kyc-api",
"providerVersion": "1.0.16-SNAPSHOT"
},
"interactions": [
{
"communicationInterface": "rest",
"interactionName": "KYC API - Update Complate flag",
"validationResult": "FAILED",
"errors": [
"Object instance has properties which are not allowed by the schema: ["status"]"
]
}
]
}
]

Please sign in to comment.