Skip to content

spring-server: include path in SimpleKotlinGraphQLError error message #392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 27, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ open class SimpleKotlinGraphQLError(

override fun getLocations(): List<SourceLocation> = locations

override fun getMessage(): String = exception.message ?: "Exception was thrown while executing a GraphQL query"
override fun getMessage(): String = "Exception while fetching data (${path?.joinToString("/").orEmpty()}) : ${exception.message}"

override fun getPath(): List<Any>? = path
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ internal class SimpleKotlinGraphQLErrorTest {

@Test
fun `Message comes from the exception if set`() {
val error = SimpleKotlinGraphQLError(Throwable("foo"))
assertEquals(expected = "foo", actual = error.message)
val error = SimpleKotlinGraphQLError(exception = Throwable("foo"), path = listOf("/foo"))
assertEquals(expected = "Exception while fetching data (/foo) : foo", actual = error.message)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class QueryHandlerTest {
val error = errors.first()
assertTrue(error is SimpleKotlinGraphQLError)
assertEquals(ErrorType.DataFetchingException, error.errorType)
assertEquals("Uncaught JUNIT", error.message)
assertEquals("Exception while fetching data () : Uncaught JUNIT", error.message)
}
assertNull(response.extensions)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class SubscriptionHandlerTest {
assertNotNull(response.errors) { errors ->
assertEquals(1, errors.size)
val error = errors.first()
assertEquals("JUNIT subscription failure", error.message)
assertEquals("Exception while fetching data () : JUNIT subscription failure", error.message)
assertEquals(ErrorType.DataFetchingException, error.errorType)
}
assertNull(response.extensions)
Expand Down