Commit 2a57b114 authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Create definite error for case, when projects has no branches.

parent cce7b411
......@@ -15,6 +15,7 @@ import ru.terrakok.gitlabclient.entity.app.target.TargetHeaderTitle
import ru.terrakok.gitlabclient.entity.event.EventAction
import ru.terrakok.gitlabclient.entity.todo.TodoAction
import ru.terrakok.gitlabclient.model.system.ResourceManager
import ru.terrakok.gitlabclient.presentation.project.files.NoBranchesError
import java.io.IOException
/**
......@@ -35,6 +36,7 @@ fun Throwable.userMessage(resourceManager: ResourceManager) = when (this) {
else -> resourceManager.getString(R.string.unknown_error)
}
is IOException -> resourceManager.getString(R.string.network_error)
is NoBranchesError -> resourceManager.getString(R.string.project_files_no_branches)
else -> resourceManager.getString(R.string.unknown_error)
}
......
package ru.terrakok.gitlabclient.presentation.project.files
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 04.01.19.
*/
class NoBranchesError : RuntimeException()
\ No newline at end of file
......@@ -121,7 +121,7 @@ class ProjectFilesPresenter @Inject constructor(
projectFileDestination.init(project.path, project.defaultBranch)
projectFileDestination.moveToRoot()
} else {
handleLoadingProjectDetailsError(null)
handleLoadingProjectDetailsError(NoBranchesError())
}
},
{ handleLoadingProjectDetailsError(it) }
......@@ -129,14 +129,10 @@ class ProjectFilesPresenter @Inject constructor(
.connect()
}
private fun handleLoadingProjectDetailsError(error: Throwable?) {
private fun handleLoadingProjectDetailsError(error: Throwable) {
viewState.setPath(resourceManager.getString(R.string.project_files_default_path))
viewState.showBranchSelection(false)
if (error != null) {
errorHandler.proceed(error, { viewState.showEmptyError(true, it) })
} else {
viewState.showEmptyError(true, resourceManager.getString(R.string.project_files_no_branches))
}
errorHandler.proceed(error, { viewState.showEmptyError(true, it) })
}
private val paginator = Paginator(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment