error-handling

command
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Error Handling Example

Shows different ways to handle validation errors and parse failures.

What it shows

  • Multiple validation errors in a single validation
  • Different error output formats
  • JSON parsing errors
  • Unmarshal validation errors
  • Error type checking

Error Types

  • Validation errors: Field-specific constraint violations
  • Parse errors: Invalid JSON syntax
  • Unmarshal errors: Validation failures during unmarshaling

Run

go run main.go

Output

Error Handling Examples
=======================
1. Multiple validation errors:
   Errors:
   - name: Value should be at least 2 characters long
   - age: Value should be at least 18
   - email: Unsupported format 'email'
   - score: Value should be at most 100

2. Error list format:
   - name: Value should be at least 2 characters long
   - age: Value should be at least 18
   - email: Unsupported format 'email'
   - score: Value should be at most 100

3. JSON parse error:
   JSON parsing failed

4. Unmarshal error:
   Unmarshal failed: validation failed
   Error type: validation

5. Successful validation:
   ✅ Validation passed

Documentation

Overview

Package main demonstrates error-handling usage of the jsonschema library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL