All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.nemerosa.ontrack.kdsl.connector.graphql.GraphQLClientException.kt Maven / Gradle / Ivy

There is a newer version: 4.4.5
Show newest version
package net.nemerosa.ontrack.kdsl.connector.graphql

import com.apollographql.apollo.api.Error

class GraphQLClientException(message: String) : RuntimeException(message) {

    companion object {

        fun errors(errors: List) = GraphQLClientException(
            message = errorsMessage(errors)
        )

        private fun errorsMessage(errors: List): String =
            errors.map { errorMessage(it) }.joinToString("\n") { "* $it" }

        private fun errorMessage(error: Error): String {
            val base = error.message
            return if (error.locations.isNotEmpty()) {
                "$base. Locations: ${error.locations.joinToString { location -> locationMessage(location) }}"
            } else {
                "$base."
            }
        }

        private fun locationMessage(location: Error.Location) =
            "${location.line},${location.column}"

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy