Skip to content

Commit 86e1d47

Browse files
committed
fix(model-server): throw more specific exception when reverting non-existent branch
1 parent d6c3a02 commit 86e1d47

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

model-server/src/main/kotlin/org/modelix/model/server/handlers/ui/HistoryHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import org.modelix.model.operations.RevertToOp
6666
import org.modelix.model.operations.applyOperation
6767
import org.modelix.model.persistent.CPVersion.Companion.DESERIALIZER
6868
import org.modelix.model.server.ModelServerPermissionSchema
69+
import org.modelix.model.server.handlers.BranchNotFoundException
6970
import org.modelix.model.server.handlers.IRepositoriesManager
7071
import org.modelix.model.server.templates.PageWithMenuBar
7172
import java.time.LocalDateTime
@@ -128,7 +129,7 @@ class HistoryHandler(val client: IModelClient, private val repositoriesManager:
128129
}
129130

130131
private suspend fun revert(repositoryAndBranch: BranchReference, from: String?, to: String?, author: String?) {
131-
val version = repositoriesManager.getVersion(repositoryAndBranch) ?: throw RuntimeException("Branch doesn't exist: $repositoryAndBranch")
132+
val version = repositoriesManager.getVersion(repositoryAndBranch) ?: throw BranchNotFoundException(repositoryAndBranch)
132133
val branch = OTBranch(PBranch(version.getTree(), client.idGenerator), client.idGenerator, client.storeCache)
133134
branch.runWriteT { t ->
134135
t.applyOperation(RevertToOp(KVEntryReference(from!!, DESERIALIZER), KVEntryReference(to!!, DESERIALIZER)))

0 commit comments

Comments
 (0)