Skip to content

Commit 9158f35

Browse files
committed
Improve bundling-related invalid JSON errors
Signed-off-by: Juan Cruz Viotti <[email protected]>
1 parent 9c0727b commit 9158f35

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/core/jsonschema/bundle.cc

+6-4
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,16 @@ auto bundle_schema(sourcemeta::core::JSON &root, const std::string &container,
105105
sourcemeta::core::JSON copy{remote.value()};
106106

107107
if (!sourcemeta::core::is_schema(copy)) {
108-
throw sourcemeta::core::SchemaResolutionError(
109-
identifier, "The JSON document is not a valid JSON Schema");
108+
throw sourcemeta::core::SchemaReferenceError(
109+
identifier, key.second,
110+
"The JSON document is not a valid JSON Schema");
110111
}
111112

112113
const auto dialect{sourcemeta::core::dialect(copy, default_dialect)};
113114
if (!dialect.has_value()) {
114-
throw sourcemeta::core::SchemaResolutionError(
115-
identifier, "The JSON document is not a valid JSON Schema");
115+
throw sourcemeta::core::SchemaReferenceError(
116+
identifier, key.second,
117+
"The JSON document is not a valid JSON Schema");
116118
}
117119

118120
if (copy.is_object()) {

test/jsonschema/jsonschema_bundle_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ TEST(JSONSchema_bundle, target_no_dialect) {
168168
EXPECT_THROW(
169169
sourcemeta::core::bundle(
170170
document, sourcemeta::core::schema_official_walker, test_resolver),
171-
sourcemeta::core::SchemaResolutionError);
171+
sourcemeta::core::SchemaReferenceError);
172172
}
173173

174174
TEST(JSONSchema_bundle, target_array) {
@@ -182,5 +182,5 @@ TEST(JSONSchema_bundle, target_array) {
182182
EXPECT_THROW(
183183
sourcemeta::core::bundle(
184184
document, sourcemeta::core::schema_official_walker, test_resolver),
185-
sourcemeta::core::SchemaResolutionError);
185+
sourcemeta::core::SchemaReferenceError);
186186
}

0 commit comments

Comments
 (0)