Skip to content

Commit

Permalink
use varargs in ParsingError
Browse files Browse the repository at this point in the history
  • Loading branch information
redmitry committed Nov 3, 2023
1 parent 3663741 commit d6e28a7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/es/elixir/bsc/json/schema/ParsingError.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ParsingError(ParsingMessage message) {
this.message = message.VALUE;
}

public ParsingError(ParsingMessage message, Object args) {
public ParsingError(ParsingMessage message, Object... args) {
this.code = message.CODE;
this.message = String.format(message.VALUE, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ public JsonSchema read(JsonSchemaLocator locator) throws JsonSchemaException {
obj = locator.getSchema("/");
} catch (IOException ex) {
throw new JsonSchemaException(
new ParsingError(ParsingMessage.UNRESOLVABLE_SCHEMA, new Object[] {locator.uri}));
new ParsingError(ParsingMessage.UNRESOLVABLE_SCHEMA, locator.uri));
} catch (JsonException ex) {
throw new JsonSchemaException(
new ParsingError(ParsingMessage.JSON_PARSING_ERROR, new Object[] {ex.getMessage()}));
new ParsingError(ParsingMessage.JSON_PARSING_ERROR, ex.getMessage()));
}
schema = new DefaultJsonSchemaParser(properties).parse(locator, obj);
schemas.put(locator.uri, schema);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* *****************************************************************************
* Copyright (C) 2022 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* Copyright (C) 2023 ELIXIR ES, Spanish National Bioinformatics Institute (INB)
* and Barcelona Supercomputing Center (BSC)
*
* Modifications to the initial code base are copyright of their respective
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public JsonAnyOfImpl read(final JsonSubschemaParser parser,
add(parser.parse(getScope(), parent, getJsonPointer(), value, t));
} catch(IllegalArgumentException ex) {
throw new JsonSchemaException(
new ParsingError(ParsingMessage.UNKNOWN_OBJECT_TYPE, new Object[] {val}));
new ParsingError(ParsingMessage.UNKNOWN_OBJECT_TYPE, val));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public JsonRecursiveReferenceImpl read(final JsonSubschemaParser parser,
final JsonString jrecursive_ref = JsonSchemaUtil.check(object.get(RECURSIVE_REF), JsonValue.ValueType.STRING);
if (!"#".equals(jrecursive_ref.getString())) {
throw new JsonSchemaException(
new ParsingError(ParsingMessage.INVALID_REFERENCE, new Object[] {jrecursive_ref.getString()}));
new ParsingError(ParsingMessage.INVALID_REFERENCE, jrecursive_ref.getString()));
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public JsonSchemaElement getSchema() throws JsonSchemaException {
JsonValue jsubschema = ref_locator.getSchema(ref_pointer);
if (jsubschema == null) {
throw new JsonSchemaException(
new ParsingError(ParsingMessage.UNRESOLVABLE_REFERENCE, new Object[] {ref}));
new ParsingError(ParsingMessage.UNRESOLVABLE_REFERENCE, ref));
}

schema = parser.parse(ref_locator, getParent(), ref_pointer, jsubschema, null);
} catch(IOException | JsonException | IllegalArgumentException ex) {
throw new JsonSchemaException(
new ParsingError(ParsingMessage.INVALID_REFERENCE, new Object[] {ref}));
new ParsingError(ParsingMessage.INVALID_REFERENCE, ref));
}
}
return schema;
Expand Down Expand Up @@ -132,7 +132,7 @@ public JsonReferenceImpl read(final JsonSubschemaParser parser,
}
} catch(JsonException | IllegalArgumentException | URISyntaxException ex) {
throw new JsonSchemaException(
new ParsingError(ParsingMessage.INVALID_REFERENCE, new Object[] {ref}));
new ParsingError(ParsingMessage.INVALID_REFERENCE, ref));
}

return this;
Expand Down

0 comments on commit d6e28a7

Please sign in to comment.