Skip to content

Commit 19941fd

Browse files
committed
Rename JsonSchemaException to SchemaException
1 parent 9eed0cc commit 19941fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+97
-97
lines changed

src/main/java/com/networknt/schema/FailFastAssertionException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/**
2424
* Thrown when an assertion happens and the evaluation can fail fast.
2525
* <p>
26-
* This doesn't extend off JsonSchemaException as it is used for flow control
26+
* This doesn't extend off SchemaException as it is used for flow control
2727
* and is intended to be caught in a specific place.
2828
* <p>
2929
* This will be caught in the JsonSchema validate method to be passed to the

src/main/java/com/networknt/schema/InvalidSchemaException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* Thrown when an invalid schema is used.
2323
*/
24-
public class InvalidSchemaException extends JsonSchemaException {
24+
public class InvalidSchemaException extends SchemaException {
2525
private static final long serialVersionUID = 1L;
2626

2727
public InvalidSchemaException(Error message, Exception cause) {

src/main/java/com/networknt/schema/Schema.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public Schema getRefSchema(JsonNodePath fragment) {
438438
result = this.schemaContext.getDynamicAnchors().get(anchor);
439439
}
440440
if (result == null) {
441-
throw new JsonSchemaException("Unable to find anchor "+anchor);
441+
throw new SchemaException("Unable to find anchor "+anchor);
442442
}
443443
return result;
444444
}
@@ -634,7 +634,7 @@ private List<KeywordValidator> read(JsonNode schemaNode) {
634634
.schemaLocation(schemaPath)
635635
.arguments(nodeToUse.getNodeType().toString())
636636
.build();
637-
throw new JsonSchemaException(error);
637+
throw new SchemaException(error);
638638
}
639639
this.recursiveAnchor = nodeToUse.booleanValue();
640640
}

src/main/java/com/networknt/schema/JsonSchemaException.java renamed to src/main/java/com/networknt/schema/SchemaException.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@
2020
import java.util.List;
2121

2222
/**
23-
* Represents an error when processing the JsonSchema.
23+
* Represents an error when processing the Schema.
2424
*/
25-
public class JsonSchemaException extends RuntimeException {
25+
public class SchemaException extends RuntimeException {
2626
private static final long serialVersionUID = -7805792737596582110L;
2727
private final Error error;
2828

29-
public JsonSchemaException(Error error) {
29+
public SchemaException(Error error) {
3030
this.error = error;
3131
}
3232

33-
public JsonSchemaException(String message) {
33+
public SchemaException(String message) {
3434
super(message);
3535
this.error = null;
3636
}
3737

38-
public JsonSchemaException(Throwable throwable) {
38+
public SchemaException(Throwable throwable) {
3939
super(throwable);
4040
this.error = null;
4141
}

src/main/java/com/networknt/schema/SchemaRegistry.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ private Dialect getDialect(final JsonNode schemaNode, SchemaRegistryConfig confi
383383
private Dialect getDialectOrDefault(final JsonNode schemaNode) {
384384
final JsonNode iriNode = schemaNode.get("$schema");
385385
if (iriNode != null && !iriNode.isNull() && !iriNode.isTextual()) {
386-
throw new JsonSchemaException("Unknown dialect: " + iriNode);
386+
throw new SchemaException("Unknown dialect: " + iriNode);
387387
}
388388
final String iri = iriNode == null || iriNode.isNull() ? defaultDialectId : iriNode.textValue();
389389
return getDialect(iri);
@@ -437,7 +437,7 @@ public Schema getSchema(final String schema, InputFormat inputFormat) {
437437
return newSchema(null, schemaNode);
438438
} catch (IOException ioe) {
439439
logger.error("Failed to load json schema!", ioe);
440-
throw new JsonSchemaException(ioe);
440+
throw new SchemaException(ioe);
441441
}
442442
}
443443

@@ -470,7 +470,7 @@ public Schema getSchema(final InputStream schemaStream, InputFormat inputFormat)
470470
return newSchema(null, schemaNode);
471471
} catch (IOException ioe) {
472472
logger.error("Failed to load json schema!", ioe);
473-
throw new JsonSchemaException(ioe);
473+
throw new SchemaException(ioe);
474474
}
475475
}
476476

@@ -542,7 +542,7 @@ protected Schema getMappedSchema(final SchemaLocation schemaUri) {
542542
}
543543
} catch (IOException e) {
544544
logger.error("Failed to load json schema from {}", schemaUri.getAbsoluteIri(), e);
545-
JsonSchemaException exception = new JsonSchemaException("Failed to load json schema from "+schemaUri.getAbsoluteIri());
545+
SchemaException exception = new SchemaException("Failed to load json schema from "+schemaUri.getAbsoluteIri());
546546
exception.initCause(e);
547547
throw exception;
548548
}

src/main/java/com/networknt/schema/SpecificationVersionDetector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ private SpecificationVersionDetector() {
5252

5353
/**
5454
* Detects schema version based on the schema tag: if the schema tag is not present, throws
55-
* {@link JsonSchemaException} with the corresponding message, otherwise - returns the detected spec version.
55+
* {@link SchemaException} with the corresponding message, otherwise - returns the detected spec version.
5656
*
5757
* @param jsonNode JSON Node to read from
5858
* @return Spec version if present, otherwise throws an exception
5959
*/
6060
public static Version detect(JsonNode jsonNode) {
6161
return detectOptionalVersion(jsonNode, true).orElseThrow(
62-
() -> new JsonSchemaException("'" + SCHEMA_TAG + "' tag is not present")
62+
() -> new SchemaException("'" + SCHEMA_TAG + "' tag is not present")
6363
);
6464
}
6565

@@ -79,7 +79,7 @@ public static Optional<Version> detectOptionalVersion(JsonNode jsonNode, boolean
7979

8080
if (throwIfUnsupported) {
8181
return Version.fromDialectId(schemaUri)
82-
.orElseThrow(() -> new JsonSchemaException("'" + schemaTagValue + "' is unrecognizable schema"));
82+
.orElseThrow(() -> new SchemaException("'" + schemaTagValue + "' is unrecognizable schema"));
8383
} else {
8484
return Version.fromDialectId(schemaUri).orElse(null);
8585
}

src/main/java/com/networknt/schema/dialect/Dialect.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import com.networknt.schema.InvalidSchemaException;
2323
import com.networknt.schema.JsonNodePath;
2424
import com.networknt.schema.Schema;
25-
import com.networknt.schema.JsonSchemaException;
25+
import com.networknt.schema.SchemaException;
2626
import com.networknt.schema.SchemaLocation;
2727
import com.networknt.schema.Specification;
2828
import com.networknt.schema.SchemaContext;
@@ -470,17 +470,17 @@ public KeywordValidator newValidator(SchemaContext schemaContext, SchemaLocation
470470
}
471471
return kw.newValidator(schemaLocation, evaluationPath, schemaNode, parentSchema, schemaContext);
472472
} catch (InvocationTargetException e) {
473-
if (e.getTargetException() instanceof JsonSchemaException) {
473+
if (e.getTargetException() instanceof SchemaException) {
474474
logger.error("Error:", e);
475-
throw (JsonSchemaException) e.getTargetException();
475+
throw (SchemaException) e.getTargetException();
476476
}
477477
logger.warn("Could not load validator {}", keyword);
478-
throw new JsonSchemaException(e.getTargetException());
479-
} catch (JsonSchemaException e) {
478+
throw new SchemaException(e.getTargetException());
479+
} catch (SchemaException e) {
480480
throw e;
481481
} catch (Exception e) {
482482
logger.warn("Could not load validator {}", keyword);
483-
throw new JsonSchemaException(e);
483+
throw new SchemaException(e);
484484
}
485485
}
486486

src/main/java/com/networknt/schema/keyword/AllOfValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import com.networknt.schema.ExecutionContext;
2525
import com.networknt.schema.JsonNodePath;
2626
import com.networknt.schema.Schema;
27-
import com.networknt.schema.JsonSchemaException;
27+
import com.networknt.schema.SchemaException;
2828
import com.networknt.schema.JsonType;
2929
import com.networknt.schema.SchemaLocation;
3030
import com.networknt.schema.TypeFactory;
@@ -40,7 +40,7 @@ public AllOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath
4040
super(ValidatorTypeCode.ALL_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath);
4141
if (!schemaNode.isArray()) {
4242
JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig());
43-
throw new JsonSchemaException(error().instanceNode(schemaNode)
43+
throw new SchemaException(error().instanceNode(schemaNode)
4444
.instanceLocation(schemaLocation.getFragment())
4545
.messageKey("type")
4646
.arguments(nodeType.toString(), "array")

src/main/java/com/networknt/schema/keyword/AnyOfValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import com.networknt.schema.ExecutionContext;
2323
import com.networknt.schema.JsonNodePath;
2424
import com.networknt.schema.Schema;
25-
import com.networknt.schema.JsonSchemaException;
25+
import com.networknt.schema.SchemaException;
2626
import com.networknt.schema.JsonType;
2727
import com.networknt.schema.SchemaLocation;
2828
import com.networknt.schema.TypeFactory;
@@ -44,7 +44,7 @@ public AnyOfValidator(SchemaLocation schemaLocation, JsonNodePath evaluationPath
4444
super(ValidatorTypeCode.ANY_OF, schemaNode, schemaLocation, parentSchema, schemaContext, evaluationPath);
4545
if (!schemaNode.isArray()) {
4646
JsonType nodeType = TypeFactory.getValueNodeType(schemaNode, this.schemaContext.getSchemaRegistryConfig());
47-
throw new JsonSchemaException(error().instanceNode(schemaNode)
47+
throw new SchemaException(error().instanceNode(schemaNode)
4848
.instanceLocation(schemaLocation.getFragment())
4949
.messageKey("type")
5050
.arguments(nodeType.toString(), "array")

src/main/java/com/networknt/schema/keyword/DiscriminatorValidator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import com.networknt.schema.ExecutionContext;
2929
import com.networknt.schema.JsonNodePath;
3030
import com.networknt.schema.Schema;
31-
import com.networknt.schema.JsonSchemaException;
31+
import com.networknt.schema.SchemaException;
3232
import com.networknt.schema.SchemaLocation;
3333
import com.networknt.schema.SchemaContext;
3434

@@ -144,7 +144,7 @@ public static void registerAndMergeDiscriminator(final DiscriminatorContext curr
144144
// this is where A -> B -> C inheritance exists, A has the root discriminator and B adds to the mapping
145145
final JsonNode propertyName = discriminatorOnSchema.get("propertyName");
146146
if (null != propertyName) {
147-
throw new JsonSchemaException(instanceLocation + " schema " + schema + " attempts redefining the discriminator property");
147+
throw new SchemaException(instanceLocation + " schema " + schema + " attempts redefining the discriminator property");
148148
}
149149
final ObjectNode mappingOnContextDiscriminator = (ObjectNode) discriminator.get("mapping");
150150
final ObjectNode mappingOnCurrentSchemaDiscriminator = (ObjectNode) discriminatorOnSchema.get("mapping");
@@ -163,7 +163,7 @@ public static void registerAndMergeDiscriminator(final DiscriminatorContext curr
163163

164164
final JsonNode currentMappingValue = mappingOnContextDiscriminator.get(mappingKeyToAdd);
165165
if (null != currentMappingValue && currentMappingValue != mappingValueToAdd) {
166-
throw new JsonSchemaException(instanceLocation + "discriminator mapping redefinition from " + mappingKeyToAdd
166+
throw new SchemaException(instanceLocation + "discriminator mapping redefinition from " + mappingKeyToAdd
167167
+ "/" + currentMappingValue + " to " + mappingValueToAdd);
168168
} else if (null == currentMappingValue) {
169169
mappingOnContextDiscriminator.set(mappingKeyToAdd, mappingValueToAdd);

0 commit comments

Comments
 (0)