net.nemerosa.ontrack.kdsl.connector.graphql.GraphQLClientException.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ontrack-kdsl Show documentation
Show all versions of ontrack-kdsl Show documentation
Ontrack module: ontrack-kdsl
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