JSON::...::Error(3pm)

๐Ÿ“ฆ
version 0.642 ยท 4 versions
, in ubuntu stonking

๐Ÿ’– JSON::...::Error(3pm) โ€” aka JSON::Schema::Modern::Error ๐Ÿ’–

okay bestie, so this page lives in the User Contributed Perl Documentation corner of the manual, and it's all about one (1) single error. One. Singular. A whole class just to hold one little error from a JSON Schema evaluation. The audacity? Iconic, honestly. โœจ


๐ŸŒธ NAME ๐ŸŒธ

JSON::Schema::Modern::Error โ€” she contains a single error from a JSON Schema evaluation. That's it, that's her whole job, and she does it flawlessly. ๐Ÿ’…


โญ VERSION โญ

version 0.642

So here's the tea: the version numbering goes up linearly. That's it. Do not read anything into the version being less than 1.0 โ€” no meaning should be presumed or inferred from that, okay? It's giving "numbers go brrr", not "this is unfinished". ๐Ÿซถ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

use JSON::Schema::Modern;
my $js = JSON::Schema::Modern->new;
my $result = $js->evaluate($data, $schema);
my @errors = $result->errors;

my $message = $errors[0]->error;
my $instance_location = $errors[0]->instance_location;

my $errors_encoded = encode_json(\@errors);

look at her go. โœจ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

An instance of this class holds one error from evaluating a JSON Schema with JSON::Schema::Modern. One error per object. No sharing, no blending, we are not doing group projects here. ๐Ÿ’€


๐Ÿ’œ ATTRIBUTES ๐Ÿ’œ

๐Ÿ”ฅ keyword

The keyword that produced the error. Might be undef โ€” yes, she can be mysterious like that. ๐Ÿ™ˆ

๐ŸŒˆ instance_location

The path in the instance where the error occurred, encoded as per the JSON Pointer specification (RFC 6901 <https://datatracker.ietf.org/doc/html/rfc6901>). It knows exactly where it happened. Forensic queen. ๐Ÿ‘‘

โญ keyword_location

The schema path that was taken during evaluation to arrive at the error, encoded as per the JSON Pointer specification (RFC 6901 <https://datatracker.ietf.org/doc/html/rfc6901>). Receipts. She has receipts. ๐Ÿงพ

๐ŸŒธ absolute_keyword_location

The canonical URI or URI reference of the location in the schema where the error occurred. This one is not defined if there's no base URI for the schema and no $ref was followed. Also lowkey important: this is not a fragmentless URI in most cases, because the indicated error happens at a path below the position where the most recent identifier had been declared in the schema. And further โ€” if the schema never declared an absolute base URI (like, one containing a scheme), then this URI won't be absolute either. It's giving "absolute in name only". ๐Ÿ˜ญ

๐Ÿ’– error

The actual error string. The words. The moment. โœจ

๐ŸŽ€ exception

Indicates that the error's severity is sufficient to stop evaluation. She said "we're done here" and she meant it. ๐Ÿ›‘

A tuple consisting of [ integer, string ] โ€” the recommended HTTP response code and the string to use for this error, if you're validating an HTTP request. This can exist for stuff like a failed authentication check in OpenAPI validation, in which case it would contain [ 401, 'Unauthorized' ]. โœ‹

The string can be omitted at construction time, in which case it gets populated from the standard list of error strings corresponding to HTTP response codes (see RFC9110 ยง15). She'll fill in the blanks for you, bestie. ๐Ÿซถ

๐Ÿงš depth

An integer that tells you how many subschemas deep this error was generated from. You can use it to construct a tree-like structure of errors. It's literally the family tree of your mistakes. ๐ŸŒณ


โœจ METHODS โœจ

๐Ÿ”ฎ TO_JSON

Returns a data structure suitable for serialization. Corresponds to one output unit as specified in <https://json-schema.org/draft/2020-12/json-schema-core#section-12.3> and <https://json-schema.org/draft/2020-12/output/schema>, except that instanceLocation and keywordLocation are JSON pointers, not URI fragments, even in draft2019-09. (See the strict_basic output_format in JSON::Schema::Modern โ€” only available in that version โ€” if that distinction is important to you. iykyk.)

๐Ÿ’ซ dump

Returns a JSON string representing the error object, according to the specification <https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.10>. Rendered. Pretty. Slay.

๐ŸŒŸ clone

my $new_error = $error->clone(instance_location => '/new/location');

Creates a clone of an existing error object, with some optional modifications to existing properties. Glow-up but make it a copy. ๐Ÿ’…


๐Ÿซถ GIVING THANKS ๐Ÿซถ

If you found this module to be useful, please show your appreciation by adding a +1 in MetaCPAN <https://metacpan.org/dist/JSON-Schema-Modern> and a star in GitHub <https://github.com/karenetheridge/JSON-Schema-Modern>. it costs you nothing and it means everything, fr fr. โญ


๐Ÿ’€ SUPPORT ๐Ÿ’€

Bugs may be submitted through <https://github.com/karenetheridge/JSON-Schema-Modern/issues>. (that's the main character route for problem reporting, bestie.)

I am also usually active on irc, as 'ether' at irc.perl.org and irc.libera.chat. come say hi!! ๐Ÿฆ‹

You can also find me on the JSON Schema Slack server <https://json-schema.slack.com> and OpenAPI Slack server <https://open-api.slack.com>, which are also great resources for finding help. Group chat energy, but for schemas. ๐Ÿ’ฌ


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Karen Etheridge <ether@cpan.org> โ€” the icon, the legend, the whole vibe. ๐Ÿ’œ


This software is copyright (c) 2020 by Karen Etheridge.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Some schema files have their own licence, in share/LICENSE. yes, plural licences, each file minding its own business. ๐ŸŽ€


and that's the whole page, bestie!! ๐Ÿ’–

this was perl v5.40.1, dated 2026-07-31, from the JSON::...::Error(3pm) manpage โ€” thanks for reading, ily, go validate some schemas. ๐Ÿงšโœจ๐ŸŒธ

๐Ÿ“ฆ where this page comes from