Skip to main content

Create console error reports for YAML (and JSON) documents

Project description

yaml-error-report

pipeline status coverage report

Generate rich console errors reports for YAML (and JSON, since its a YAML subset) documents. This is aimed at console tools which want to present the user with useful errors messages if a YAML or JSON document fails some internal validation.

Uses PyYaml to extract location (line, column, position in stream) information for nodes in a YAML or JSON document. This information can then be used to create user friendly error reports.

Can be combined with jsonschema, to greatly improve error messages. See examples\with_jsonschema.

Installation

pip install yaml-error-report

Usage

# calc.yml
name: calc

methods:
  - name: sum
    description: "Sums x and y"
    request:
      - name: "x"
        type: Int36
      - name: "y"
        type: Int32
    response: Int32
# windows only: needed to make coloured output work
import colorama
colorama.init()

from yaml_error_report import path_to_location, error_report

# extract the text location of the offending node
loc = path_to_location("calc.yml", ["methods", 0, "request", 0, "type"])
# create the error report
error = error_report("YAML Validation Error", "Int36 is not a valid type", loc)
print(error)

outputs (nicely coloured on terminals)

YAML Validation Error
   --> calc.yml:8:14
   7|         - name: "x"
   8|           type: Int36
                      ^^^^^ Int36 is not a valid type
   9|         - name: "y"
  10|           type: Int32

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

yaml_error_report-0.1.0-py3-none-any.whl (6.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page