Skip to content

show error details when fetching children fails (#28) #654

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
Aug 23, 2023
Merged
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 @@ -248,9 +248,36 @@ open class TreeStructure(
project
) {
override fun getLabel(element: java.lang.Exception): String {
return "Error: ${element.message ?: "unspecified"}"
return "Error: ${getMessage(element)}"
}

private fun getMessage(e: Exception): String {
val causeMessage = e.cause?.message
return if (causeMessage == null) {
getMessageOrDefault(e)
} else if (causeMessage.contains("Operation: ")) {
/**
* ex. minikube: KubernetesClientException:
* "Operation: [list] for kind: [Service] with name: [null] in namespace: [default] failed."
*/
return e.cause?.cause?.message
?: getMessageOrDefault(e)
} else {
/**
* ex. OpenShift: KubernetesClientException:
* "Failure executing: GET at: https://api.sandbox-m3.1530.p1.openshiftapps.com:6443/apis/project.openshift.io/v1/projects.
* Message: Unauthorized! Token may have expired! Please log-in again. Unauthorized."
*/
causeMessage.substringAfter("Message: ", causeMessage)
}
}

private fun getMessageOrDefault(e: Exception): String {
return e.message
?: "unspecified"
}


override fun getIcon(element: java.lang.Exception): Icon {
return AllIcons.General.BalloonError
}
Expand Down