Skip to content

Commit

Permalink
WriteParticipantPruningService propagates rich error codes on prune f…
Browse files Browse the repository at this point in the history
…ailure [DPP-861] (#13238)

changelog_begin
changelog_end
  • Loading branch information
pbatko-da committed Mar 10, 2022
1 parent d891a9a commit b663a1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Expand Up @@ -23,6 +23,7 @@ import com.daml.platform.ApiOffset.ApiOffsetConverter
import com.daml.platform.api.grpc.GrpcApiService
import com.daml.platform.apiserver.services.logging
import com.daml.platform.server.api.ValidationLogger
import com.daml.platform.server.api.validation.ErrorFactories
import io.grpc.{ServerServiceDefinition, StatusRuntimeException}

import scala.concurrent.{ExecutionContext, Future}
Expand Down Expand Up @@ -110,7 +111,7 @@ final class ApiParticipantPruningService private (
.prune(pruneUpTo, submissionId, pruneAllDivulgedContracts)
.asScala
.flatMap {
case NotPruned(status) => Future.failed(status.asRuntimeException())
case NotPruned(status) => Future.failed(ErrorFactories.grpcError(status))
case ParticipantPruned =>
logger.info(s"Pruned participant ledger up to ${pruneUpTo.toApiString} inclusively.")
Future.successful(())
Expand Down
Expand Up @@ -333,7 +333,13 @@ object RunnerSpec {
submissionId: Ref.SubmissionId,
pruneAllDivulgedContracts: Boolean,
): CompletionStage[PruningResult] = CompletableFuture.completedFuture(
PruningResult.NotPruned(Status.UNIMPLEMENTED.withDescription("prune"))
PruningResult.NotPruned(
com.google.rpc.Status
.newBuilder()
.setCode(Status.UNIMPLEMENTED.getCode.value())
.setMessage("prune")
.build()
)
)
}
})
Expand Down
Expand Up @@ -3,7 +3,7 @@

package com.daml.ledger.participant.state.v2

import io.grpc.Status
import com.google.rpc.Status

sealed trait PruningResult extends Product with Serializable

Expand Down

0 comments on commit b663a1c

Please sign in to comment.