diff --git a/src/main/kotlin/app/git/TabState.kt b/src/main/kotlin/app/git/TabState.kt index 731dbcb..96e3127 100644 --- a/src/main/kotlin/app/git/TabState.kt +++ b/src/main/kotlin/app/git/TabState.kt @@ -95,13 +95,18 @@ class TabState @Inject constructor( } } - fun runOperation(block: suspend (git: Git) -> RefreshType) = managerScope.launch(Dispatchers.IO) { + fun runOperation(showError: Boolean = false, block: suspend (git: Git) -> RefreshType) = managerScope.launch(Dispatchers.IO) { operationRunning = true try { val refreshType = block(safeGit) if (refreshType != RefreshType.NONE) _refreshData.emit(refreshType) + } catch (ex: Exception) { + ex.printStackTrace() + + if (showError) + errorsManager.addError(newErrorNow(ex, ex.localizedMessage)) } finally { operationRunning = false } diff --git a/src/main/kotlin/app/viewmodels/MenuViewModel.kt b/src/main/kotlin/app/viewmodels/MenuViewModel.kt index 310a5be..f4d845e 100644 --- a/src/main/kotlin/app/viewmodels/MenuViewModel.kt +++ b/src/main/kotlin/app/viewmodels/MenuViewModel.kt @@ -5,7 +5,6 @@ import app.git.RemoteOperationsManager import app.git.StashManager import app.git.TabState import java.awt.Desktop -import java.io.File import javax.inject.Inject class MenuViewModel @Inject constructor( @@ -41,7 +40,7 @@ class MenuViewModel @Inject constructor( return@safeProcessing RefreshType.UNCOMMITED_CHANGES } - fun openFolderInFileExplorer() = tabState.runOperation { git -> + fun openFolderInFileExplorer() = tabState.runOperation (showError = true) { git -> Desktop.getDesktop().open(git.repository.directory.parentFile) return@runOperation RefreshType.NONE