@@ -30,6 +30,7 @@ import com.redhat.devtools.intellij.kubernetes.model.util.hasDeletionTimestamp
30
30
import com.redhat.devtools.intellij.kubernetes.model.util.isSameResource
31
31
import com.redhat.devtools.intellij.kubernetes.model.util.isWillBeDeleted
32
32
import io.fabric8.kubernetes.api.model.HasMetadata
33
+ import org.bouncycastle.asn1.x509.CRLReason.unspecified
33
34
import javax.swing.Icon
34
35
35
36
/* *
@@ -248,9 +249,36 @@ open class TreeStructure(
248
249
project
249
250
) {
250
251
override fun getLabel (element : java.lang.Exception ): String {
251
- return " Error: ${element.message ? : " unspecified " } "
252
+ return " Error: ${getMessage( element) } "
252
253
}
253
254
255
+ private fun getMessage (e : Exception ): String {
256
+ val causeMessage = e.cause?.message
257
+ return if (causeMessage == null ) {
258
+ getMessageOrDefault(e)
259
+ } else if (causeMessage.contains(" Operation: " )) {
260
+ /* *
261
+ * ex. minikube: KubernetesClientException:
262
+ * "Operation: [list] for kind: [Service] with name: [null] in namespace: [default] failed."
263
+ */
264
+ return e.cause?.cause?.message
265
+ ? : getMessageOrDefault(e)
266
+ } else {
267
+ /* *
268
+ * ex. OpenShift: KubernetesClientException:
269
+ * "Failure executing: GET at: https://api.sandbox-m3.1530.p1.openshiftapps.com:6443/apis/project.openshift.io/v1/projects.
270
+ * Message: Unauthorized! Token may have expired! Please log-in again. Unauthorized."
271
+ */
272
+ causeMessage.substringAfter(" Message: " , causeMessage)
273
+ }
274
+ }
275
+
276
+ private fun getMessageOrDefault (e : Exception ): String {
277
+ return e.message
278
+ ? : " unspecified"
279
+ }
280
+
281
+
254
282
override fun getIcon (element : java.lang.Exception ): Icon {
255
283
return AllIcons .General .BalloonError
256
284
}
0 commit comments