diff --git a/code/service/src/main/scala/com/namely/chiefofstate/AggregateCommandHandler.scala b/code/service/src/main/scala/com/namely/chiefofstate/AggregateCommandHandler.scala index 8d47ede8..9eca6480 100644 --- a/code/service/src/main/scala/com/namely/chiefofstate/AggregateCommandHandler.scala +++ b/code/service/src/main/scala/com/namely/chiefofstate/AggregateCommandHandler.scala @@ -218,7 +218,7 @@ class AggregateCommandHandler( def handleGrpcResponseFailure(status: Status): CommandHandlerResponse = { val rpcStatus: RpcStatus = RpcStatus() .withCode(status.getCode.value) - .withMessage(status.getDescription) + .withMessage(Option(status.getDescription).getOrElse("")) val failureResponse = FailureResponse() .withCustom(Any.pack(rpcStatus)) diff --git a/code/service/src/test/scala/com/namely/chiefofstate/AggregateCommandHandlerSpec.scala b/code/service/src/test/scala/com/namely/chiefofstate/AggregateCommandHandlerSpec.scala index 5154d86d..c44b82df 100644 --- a/code/service/src/test/scala/com/namely/chiefofstate/AggregateCommandHandlerSpec.scala +++ b/code/service/src/test/scala/com/namely/chiefofstate/AggregateCommandHandlerSpec.scala @@ -358,6 +358,17 @@ class AggregateCommandHandlerSpec extends CustomActorTestkit("application.conf") actual.message shouldBe (status.getDescription()) } + "handle failed gRPC status with no description" in { + val status: Status = Status.ABORTED + val exception = new StatusRuntimeException(status) + val cmdhandler = new AggregateCommandHandler(null, testHandlerSetting) + val result: CommandHandlerResponse = cmdhandler.handleRemoteResponseFailure(exception) + result.getFailure.failureType.isCustom shouldBe (true) + val actual = result.getFailure.getCustom.unpack(RpcStatus) + actual.code shouldBe (status.getCode.value) + actual.message shouldBe ("") + } + "handle failed validations sent by command handler" in { val badStatus: Status = Status.INVALID_ARGUMENT.withDescription("very invalid") val exception: StatusRuntimeException = new StatusRuntimeException(badStatus)