Skip to content
Merged
Show file tree
Hide file tree
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
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2025 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package com.redhat.devtools.gateway.util

fun Throwable.rootMessage(): String {
var cause: Throwable? = this
while (cause?.cause != null) {
cause = cause.cause
}
return cause?.message?.trim()
?: this.message?.substringAfter(":")?.trim()
?: "Unknown error"
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.redhat.devtools.gateway.openshift.OpenShiftClientFactory
import com.redhat.devtools.gateway.openshift.Projects
import com.redhat.devtools.gateway.openshift.kube.KubeConfigBuilder
import com.redhat.devtools.gateway.settings.DevSpacesSettings
import com.redhat.devtools.gateway.util.rootMessage
import com.redhat.devtools.gateway.view.InformationDialog
import com.redhat.devtools.gateway.view.ui.FilteringComboBox
import com.redhat.devtools.gateway.view.ui.PasteClipboardMenu
Expand Down Expand Up @@ -118,17 +119,6 @@ class DevSpacesOpenShiftConnectionStepView(private var devSpacesContext: DevSpac
return success
}

private fun Throwable.rootMessage(): String {
// Walk down to the root cause
var cause: Throwable? = this
while (cause?.cause != null) {
cause = cause.cause
}
return cause?.message?.trim()
?: this.message?.substringAfter(":")?.trim()
?: "Unknown error"
}

private fun loadOpenShiftConnectionSettings() {
tfServer.removeAllItems()
allServers.forEach { tfServer.addItem(it) }
Expand Down
Loading