Skip to content

Commit f35da69

Browse files
committed
show error details when fetching children fails (redhat-developer#28)
Signed-off-by: Andre Dietisheim <[email protected]>
1 parent 8354bc8 commit f35da69

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/main/kotlin/com/redhat/devtools/intellij/kubernetes/tree/TreeStructure.kt

+13-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,19 @@ open class TreeStructure(
248248
project
249249
) {
250250
override fun getLabel(element: java.lang.Exception): String {
251-
return "Error: ${element.message ?: "unspecified"}"
251+
return "Error: ${getMessage(element)}"
252+
}
253+
254+
private fun getMessage(e: Exception): String {
255+
val causeMessage = e.cause?.message
256+
/**
257+
* ex. KubernetesClientException:
258+
* "Failure executing: GET at: https://api.sandbox-m3.1530.p1.openshiftapps.com:6443/apis/project.openshift.io/v1/projects.
259+
* Message: Unauthorized! Token may have expired! Please log-in again. Unauthorized."
260+
*/
261+
return causeMessage?.substringAfter("Message: ", causeMessage)
262+
?: e.message
263+
?: "unspecified"
252264
}
253265

254266
override fun getIcon(element: java.lang.Exception): Icon {

0 commit comments

Comments
 (0)