File tree 1 file changed +28
-1
lines changed
src/main/kotlin/com/redhat/devtools/intellij/kubernetes/tree
1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -248,9 +248,36 @@ open class TreeStructure(
248
248
project
249
249
) {
250
250
override fun getLabel (element : java.lang.Exception ): String {
251
- return " Error: ${element.message ? : " unspecified " } "
251
+ return " Error: ${getMessage( element) } "
252
252
}
253
253
254
+ private fun getMessage (e : Exception ): String {
255
+ val causeMessage = e.cause?.message
256
+ return if (causeMessage == null ) {
257
+ getMessageOrDefault(e)
258
+ } else if (causeMessage.contains(" Operation: " )) {
259
+ /* *
260
+ * ex. minikube: KubernetesClientException:
261
+ * "Operation: [list] for kind: [Service] with name: [null] in namespace: [default] failed."
262
+ */
263
+ return e.cause?.cause?.message
264
+ ? : getMessageOrDefault(e)
265
+ } else {
266
+ /* *
267
+ * ex. OpenShift: KubernetesClientException:
268
+ * "Failure executing: GET at: https://api.sandbox-m3.1530.p1.openshiftapps.com:6443/apis/project.openshift.io/v1/projects.
269
+ * Message: Unauthorized! Token may have expired! Please log-in again. Unauthorized."
270
+ */
271
+ causeMessage.substringAfter(" Message: " , causeMessage)
272
+ }
273
+ }
274
+
275
+ private fun getMessageOrDefault (e : Exception ): String {
276
+ return e.message
277
+ ? : " unspecified"
278
+ }
279
+
280
+
254
281
override fun getIcon (element : java.lang.Exception ): Icon {
255
282
return AllIcons .General .BalloonError
256
283
}
You can’t perform that action at this time.
0 commit comments