Introduce a GraphqlErrorException for Kotlin users and generally. by bbakerman · Pull Request #1743 · graphql-java/graphql-java · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions src/main/java/graphql/GraphqlErrorException.java
52 changes: 4 additions & 48 deletions src/main/java/graphql/schema/CoercingParseLiteralException.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package graphql.schema;

import graphql.ErrorType;
import graphql.GraphQLError;
import graphql.GraphQLException;
import graphql.GraphqlErrorException;
import graphql.PublicApi;
import graphql.language.SourceLocation;

import java.util.Collections;
import java.util.List;
import java.util.Map;

@PublicApi
public class CoercingParseLiteralException extends GraphQLException implements GraphQLError {
private final List<SourceLocation> sourceLocations;
private final Map<String, Object> extensions;
public class CoercingParseLiteralException extends GraphqlErrorException {

public CoercingParseLiteralException() {
this(newCoercingParseLiteralException());
Expand All @@ -36,56 +29,19 @@ public CoercingParseLiteralException(Throwable cause) {
}

private CoercingParseLiteralException(Builder builder) {
super(builder.message, builder.cause);
this.sourceLocations = builder.sourceLocations;
this.extensions = builder.extensions;
}

@Override
public List<SourceLocation> getLocations() {
return sourceLocations;
super(builder);
}

@Override
public ErrorType getErrorType() {
return ErrorType.ValidationError;
}

@Override
public Map<String, Object> getExtensions() {
return extensions;
}

public static Builder newCoercingParseLiteralException() {
return new Builder();
}

public static class Builder {
private String message;
private Throwable cause;
private List<SourceLocation> sourceLocations;
private Map<String, Object> extensions;

public Builder message(String message) {
this.message = message;
return this;
}

public Builder cause(Throwable cause) {
this.cause = cause;
return this;
}

public Builder sourceLocation(SourceLocation sourceLocation) {
this.sourceLocations = sourceLocation == null ? null : Collections.singletonList(sourceLocation);
return this;
}

public Builder extensions(Map<String, Object> extensions) {
this.extensions = extensions;
return this;
}

public static class Builder extends BuilderBase<Builder, CoercingParseLiteralException> {
public CoercingParseLiteralException build() {
return new CoercingParseLiteralException(this);
}
Expand Down
57 changes: 4 additions & 53 deletions src/main/java/graphql/schema/CoercingParseValueException.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package graphql.schema;

import graphql.ErrorType;
import graphql.GraphQLError;
import graphql.GraphQLException;
import graphql.GraphqlErrorException;
import graphql.PublicApi;
import graphql.language.SourceLocation;

import java.util.Collections;
import java.util.List;
import java.util.Map;

@PublicApi
public class CoercingParseValueException extends GraphQLException implements GraphQLError {
private final List<SourceLocation> sourceLocations;
private final Map<String, Object> extensions;
public class CoercingParseValueException extends GraphqlErrorException {

public CoercingParseValueException() {
this(newCoercingParseValueException());
Expand All @@ -36,61 +29,19 @@ public CoercingParseValueException(String message, Throwable cause, SourceLocati
}

private CoercingParseValueException(Builder builder) {
super(builder.message, builder.cause);
this.sourceLocations = builder.sourceLocations;
this.extensions = builder.extensions;
}

@Override
public List<SourceLocation> getLocations() {
return sourceLocations;
super(builder);
}

@Override
public ErrorType getErrorType() {
return ErrorType.ValidationError;
}

@Override
public Map<String, Object> getExtensions() {
return extensions;
}

public static Builder newCoercingParseValueException() {
return new Builder();
}

public static class Builder {
private String message;
private Throwable cause;
private List<SourceLocation> sourceLocations;
private Map<String, Object> extensions;

public Builder message(String message) {
this.message = message;
return this;
}

public Builder cause(Throwable cause) {
this.cause = cause;
return this;
}

public Builder sourceLocation(SourceLocation sourceLocation) {
this.sourceLocations = sourceLocation == null ? null : Collections.singletonList(sourceLocation);
return this;
}

public Builder sourceLocations(List<SourceLocation> sourceLocations) {
this.sourceLocations = sourceLocations;
return this;
}

public Builder extensions(Map<String, Object> extensions) {
this.extensions = extensions;
return this;
}

public static class Builder extends BuilderBase<Builder,CoercingParseValueException> {
public CoercingParseValueException build() {
return new CoercingParseValueException(this);
}
Expand Down
53 changes: 4 additions & 49 deletions src/main/java/graphql/schema/CoercingSerializeException.java