override fun handleException()

in graphql-dgs/src/main/kotlin/com/netflix/graphql/dgs/exceptions/DefaultDataFetcherExceptionHandler.kt [37:71]


    override fun handleException(
        handlerParameters: DataFetcherExceptionHandlerParameters,
    ): CompletableFuture<DataFetcherExceptionHandlerResult> = CompletableFuture.completedFuture(doHandleException(handlerParameters))

    private fun doHandleException(handlerParameters: DataFetcherExceptionHandlerParameters): DataFetcherExceptionHandlerResult {
        val exception = unwrapCompletionException(handlerParameters.exception)

        val graphqlError =
            when (exception) {
                is DgsException -> exception.toGraphQlError(path = handlerParameters.path)
                else -> {
                    val builder =
                        when {
                            springSecurityAvailable &&
                                isSpringSecurityAccessException(
                                    exception,
                                ) -> TypedGraphQLError.newPermissionDeniedBuilder()

                            else -> TypedGraphQLError.newInternalErrorBuilder()
                        }
                    builder
                        .message("${exception::class.java.name}: ${exception.message}")
                        .path(handlerParameters.path)
                    handlerParameters.sourceLocation?.let { builder.location(it) }
                    builder.build()
                }
            }

        logException(handlerParameters, graphqlError, exception)

        return DataFetcherExceptionHandlerResult
            .newResult()
            .error(graphqlError)
            .build()
    }