error handling

This commit is contained in:
cupcakearmy 2022-11-21 15:58:47 +01:00
parent a9e3c19fb9
commit 3c73381642
No known key found for this signature in database
GPG Key ID: 3235314B4D31232F
3 changed files with 8 additions and 3 deletions

View File

@ -25,10 +25,10 @@ $defs:
$ref: "#/$defs/font-variation" $ref: "#/$defs/font-variation"
css: css:
# https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face#descriptors
type: object type: object
additionalProperties: false additionalProperties: false
patternProperties: patternProperties:
# https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face#descriptors
? "^ascent-override|descent-override|font-display|font-family|font-stretch|font-style|font-weight|font-feature-settings|font-variation-settings|line-gap-override|size-adjust|src|unicode-range$" ? "^ascent-override|descent-override|font-display|font-family|font-stretch|font-style|font-weight|font-feature-settings|font-variation-settings|line-gap-override|size-adjust|src|unicode-range$"
: type: string : type: string

View File

@ -1,4 +1,3 @@
import copy
import hashlib import hashlib
import json import json
import os import os

View File

@ -1,5 +1,6 @@
import click import click
import jsonschema
import cmd_optimise import cmd_optimise
import flags import flags
@ -24,7 +25,12 @@ def cli(verbose, config, output_directory, clean, prefix):
# Run # Run
c = load(config) c = load(config)
try:
validate(c) validate(c)
except jsonschema.exceptions.ValidationError as e:
click.echo(f"Config validation failed:")
click.echo(f"{e.message} @ {e.json_path}")
exit(1)
cmd_optimise.optimise(c) cmd_optimise.optimise(c)