Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a0a40cd

Browse filesBrowse files
committed
Handle schema validation exception
1 parent a4d2e3a commit a0a40cd
Copy full SHA for a0a40cd

File tree

Expand file treeCollapse file tree

1 file changed

+10
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-2
lines changed

‎scripts/guideline_recategorization/recategorize.py

Copy file name to clipboardExpand all lines: scripts/guideline_recategorization/recategorize.py
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,18 @@ def main(args: argparse.Namespace):
155155
sys.exit(1)
156156

157157
coding_standards_config = cast(Mapping[str, Any], coding_standards_config)
158-
validate_against_schema(coding_standards_schema, coding_standards_config)
158+
try:
159+
validate_against_schema(coding_standards_schema, coding_standards_config)
160+
except jsonschema.ValidationError as e:
161+
print(f"Failed to validate the Coding Standards configuration file: {args.coding_standards_config_file} with the message: '{e.message}'!", file=sys.stderr)
162+
sys.exit(1)
159163

160164
sarif = json.load(args.sarif_in)
161-
validate_against_schema(sarif_schema, sarif)
165+
try:
166+
validate_against_schema(sarif_schema, sarif)
167+
except jsonschema.ValidationError as e:
168+
print(f"Failed to validate the provided Sarif with the message: '{e.message}'!", file=sys.stderr)
169+
sys.exit(1)
162170

163171
recategorizations = get_guideline_recategorizations(coding_standards_config)
164172
patch = jsonpatch.JsonPatch([patch for r in recategorizations for patch in generate_json_patches_for_recategorization(r, sarif)])

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.