override fun handle()

in plugin-bazel-event-service/src/main/kotlin/bazel/handlers/grpc/InvocationAttemptFinishedHandler.kt [13:46]


    override fun handle(ctx: GrpcEventHandlerContext): Boolean {
        if (!ctx.event.hasInvocationAttemptFinished()) {
            return false
        }

        ctx.writer.flowFinished(ctx.streamId.invocationId)

        val invocationAttemptFinished = ctx.event.invocationAttemptFinished
        val status =
            if (invocationAttemptFinished.hasInvocationStatus()) {
                invocationAttemptFinished.invocationStatus.result
            } else {
                BuildStatus.Result.UNKNOWN_STATUS
            }

        if (status == BuildStatus.Result.COMMAND_SUCCEEDED) {
            if (ctx.verbosity.atLeast(Verbosity.Detailed)) {
                ctx.writer.message("Invocation attempt completed".apply(Color.Success))
            }
        } else {
            val description = BuildStatusFormatter.format(status)
            ctx.writer.error(
                buildString {
                    append("Invocation attempt failed")
                    if (ctx.verbosity.atLeast(Verbosity.Detailed)) {
                        append(": \"$description\"")
                    }
                },
                hasPrefix = false,
            )
        }

        return true
    }