com.relogiclabs.json.schema.exception.JsonSchemaException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of relogiclabs-json-schema Show documentation
Show all versions of relogiclabs-json-schema Show documentation
The New JSON Schema prioritizes simplicity, conciseness, and readability, making
it user-friendly and accessible without the need for extensive prior knowledge.
It offers efficient read-write facilities, precise JSON document definition
through various data types and functions, and extensibility to meet modern web
service diverse requirements.
package com.relogiclabs.json.schema.exception;
import com.relogiclabs.json.schema.message.ActualDetail;
import com.relogiclabs.json.schema.message.ErrorDetail;
import com.relogiclabs.json.schema.message.ExpectedDetail;
import com.relogiclabs.json.schema.tree.Context;
import lombok.Getter;
import static com.relogiclabs.json.schema.internal.util.MiscellaneousHelper.nonNull;
@Getter
public class JsonSchemaException extends CommonException {
private final ErrorDetail error;
private final ExpectedDetail expected;
private final ActualDetail actual;
public JsonSchemaException(ErrorDetail error, ExpectedDetail expected, ActualDetail actual) {
this(error, expected, actual, null);
}
public JsonSchemaException(ErrorDetail error, ExpectedDetail expected,
ActualDetail actual, Throwable cause) {
super(error.getCode(), format(error, expected, actual), cause);
this.error = error;
this.expected = expected;
this.actual = actual;
}
private static String format(ErrorDetail error, ExpectedDetail expected, ActualDetail actual) {
Context context = nonNull(expected.getContext(), actual.getContext());
return context.getRuntime().getMessageFormatter().format(error, expected, actual);
}
}