From d0028c62dc3cb251b97c414253c27e89858094ae Mon Sep 17 00:00:00 2001 From: Patrick Strawderman Date: Fri, 4 Oct 2024 01:48:11 -0700 Subject: [PATCH] Add nullability annotations to TypedGraphQLError --- .../micrometer/MicrometerServletSmokeTest.kt | 2 +- .../graphql/types/errors/TypedGraphQLError.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/graphql-dgs-spring-boot-micrometer/src/test/kotlin/com/netflix/graphql/dgs/metrics/micrometer/MicrometerServletSmokeTest.kt b/graphql-dgs-spring-boot-micrometer/src/test/kotlin/com/netflix/graphql/dgs/metrics/micrometer/MicrometerServletSmokeTest.kt index 8e0586369..5e441538f 100644 --- a/graphql-dgs-spring-boot-micrometer/src/test/kotlin/com/netflix/graphql/dgs/metrics/micrometer/MicrometerServletSmokeTest.kt +++ b/graphql-dgs-spring-boot-micrometer/src/test/kotlin/com/netflix/graphql/dgs/metrics/micrometer/MicrometerServletSmokeTest.kt @@ -1004,7 +1004,7 @@ class MicrometerServletSmokeTest { TypedGraphQLError .newBuilder() .errorDetail(ErrorDetail.Common.ENHANCE_YOUR_CALM) - .message(exception.message) + .message(exception.message ?: "An error occurred: ${exception::class.simpleName}") .path(handlerParameters.path) .build() CompletableFuture.completedFuture( diff --git a/graphql-error-types/src/main/java/com/netflix/graphql/types/errors/TypedGraphQLError.java b/graphql-error-types/src/main/java/com/netflix/graphql/types/errors/TypedGraphQLError.java index 97365d107..01870d7ea 100644 --- a/graphql-error-types/src/main/java/com/netflix/graphql/types/errors/TypedGraphQLError.java +++ b/graphql-error-types/src/main/java/com/netflix/graphql/types/errors/TypedGraphQLError.java @@ -23,6 +23,7 @@ import graphql.GraphqlErrorHelper; import graphql.execution.ResultPath; import graphql.language.SourceLocation; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -215,13 +216,13 @@ private Map getExtensions() { return extensionsMap; } - public Builder message(String message) { + public Builder message(@NotNull String message) { this.message = assertNotNull(message); return this; } @Override - public Builder message(String message, Object... formatArgs) { + public Builder message(@NotNull String message, Object... formatArgs) { if (formatArgs == null || formatArgs.length == 0) { this.message = assertNotNull(message); } else { @@ -271,27 +272,27 @@ public Builder path(@Nullable List path) { return this; } - public Builder errorType(ErrorType errorType) { + public Builder errorType(@NotNull ErrorType errorType) { this.errorClassification = assertNotNull(errorType); return this; } - public Builder errorDetail(ErrorDetail errorDetail) { + public Builder errorDetail(@NotNull ErrorDetail errorDetail) { this.errorClassification = assertNotNull(errorDetail); return this; } - public Builder origin(String origin) { + public Builder origin(@NotNull String origin) { this.origin = assertNotNull(origin); return this; } - public Builder debugUri(String debugUri) { + public Builder debugUri(@NotNull String debugUri) { this.debugUri = assertNotNull(debugUri); return this; } - public Builder debugInfo(Map debugInfo) { + public Builder debugInfo(@NotNull Map debugInfo) { this.debugInfo = assertNotNull(debugInfo); return this; }