-
Notifications
You must be signed in to change notification settings - Fork 37
Improve rdf command error messages and documentation
#799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
|
|
||
| TMP="$(mktemp -d)" | ||
| clean() { rm -rf "$TMP"; } | ||
| trap clean EXIT | ||
|
|
||
| cat << 'EOF' > "$TMP/schema.json" | ||
| { | ||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "type": "object", | ||
| "properties": { | ||
| "price": { | ||
| "type": "number", | ||
| "x-jsonld-id": "https://schema.org/price", | ||
| "allOf": [ | ||
| { | ||
| "x-jsonld-datatype": "http://www.w3.org/2001/XMLSchema#decimal", | ||
| "x-jsonld-override": true | ||
| }, | ||
| { "x-jsonld-datatype": "http://www.w3.org/2001/XMLSchema#double" } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| EOF | ||
|
|
||
| cat << 'EOF' > "$TMP/instance.json" | ||
| { "price": 1 } | ||
| EOF | ||
|
|
||
| "$1" rdf "$TMP/schema.json" "$TMP/instance.json" 2> "$TMP/stderr.txt" \ | ||
| && EXIT_CODE="$?" || EXIT_CODE="$?" | ||
| # Schema input error | ||
| test "$EXIT_CODE" = "4" | ||
|
|
||
| cat << EOF > "$TMP/expected.txt" | ||
| error: A JSON-LD datatype cannot be assigned more than one value | ||
| at line 1 | ||
| at column 3 | ||
| at instance location "/price" | ||
| at facet "datatype" | ||
| at schema location file://$(realpath "$TMP")/schema.json#/properties/price/allOf/0/x-jsonld-datatype | ||
| at conflicting schema location file://$(realpath "$TMP")/schema.json#/properties/price/allOf/1/x-jsonld-datatype | ||
| at inert override location file://$(realpath "$TMP")/schema.json#/properties/price/allOf/0/x-jsonld-override | ||
| at file path $(realpath "$TMP")/instance.json | ||
|
|
||
| The x-jsonld-override mark was ignored because it does not enclose the | ||
| conflicting annotation. Move the conflicting annotation, or the reference | ||
| that brings it in, inside the overriding object for the override to | ||
| take effect | ||
| EOF | ||
|
|
||
| diff "$TMP/stderr.txt" "$TMP/expected.txt" | ||
|
|
||
| # JSON error | ||
| "$1" rdf "$TMP/schema.json" "$TMP/instance.json" --json > "$TMP/stdout.txt" \ | ||
| && EXIT_CODE="$?" || EXIT_CODE="$?" | ||
| # Schema input error | ||
| test "$EXIT_CODE" = "4" | ||
|
|
||
| cat << EOF > "$TMP/expected.txt" | ||
| { | ||
| "error": "A JSON-LD datatype cannot be assigned more than one value", | ||
| "line": 1, | ||
| "column": 3, | ||
| "instanceLocation": "/price", | ||
| "facet": "datatype", | ||
| "schemaLocation": "file://$(realpath "$TMP")/schema.json#/properties/price/allOf/0/x-jsonld-datatype", | ||
| "conflictingSchemaLocation": "file://$(realpath "$TMP")/schema.json#/properties/price/allOf/1/x-jsonld-datatype", | ||
| "inertOverrideLocation": "file://$(realpath "$TMP")/schema.json#/properties/price/allOf/0/x-jsonld-override", | ||
| "filePath": "$(realpath "$TMP")/instance.json" | ||
| } | ||
| EOF | ||
|
|
||
| diff "$TMP/stdout.txt" "$TMP/expected.txt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The x-jsonld-override hint block is copied verbatim into two catch handlers (
PositionError<RdfResolutionError>andRdfResolutionError) within the sametry_catchfunction. SincePositionError<T>inherits fromT, a single helper (or a small static function that takes the error reference andis_json) could print this hint once and be reused by both handlers, keeping the message in one place and making future edits to the wording less error-prone.Prompt for AI agents