Added try catch to dir opening to avoid crash if the dir has been removed
This commit is contained in:
parent
ef1e18fb91
commit
edbb095246
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user