solution: propagate native call exception to downstream

This commit is contained in:
Igor Artamonov
2019-08-23 21:39:31 -04:00
parent c9d93f91d3
commit ac30b522e6
3 changed files with 6 additions and 2 deletions

View File

@@ -75,6 +75,7 @@ class NativeCall(
}
return BlockchainOuterClass.NativeCallReplyItem.newBuilder()
.setSucceed(false)
.setErrorMessage(it?.message ?: "Internal error")
.setId(id)
.build()
.toMono()
@@ -139,7 +140,7 @@ class NativeCall(
else CallFailure(ctx.id, it)
}
.switchIfEmpty(
Mono.error<CallContext<ByteArray>>(CallFailure(ctx.id, Exception("No response or no available upstream for ${ctx.payload.method}")))
Mono.error(CallFailure(ctx.id, Exception("No response or no available upstream for ${ctx.payload.method}")) as Throwable)
)
}

View File

@@ -24,6 +24,7 @@ import io.emeraldpay.grpc.Chain
import io.infinitape.etherjar.rpc.Batch
import io.infinitape.etherjar.rpc.JacksonRpcConverter
import io.infinitape.etherjar.rpc.RpcException
import io.infinitape.etherjar.rpc.RpcResponseError
import io.infinitape.etherjar.rpc.transport.BatchStatus
import io.infinitape.etherjar.rpc.transport.RpcTransport
import reactor.core.publisher.Flux
@@ -74,7 +75,7 @@ class EthereumGrpcTransport(
bi.onError(e)
}
} else {
bi.onError(RpcException(-32603, resp.error.toString()))
bi.onError(RpcException(RpcResponseError.CODE_INTERNAL_ERROR, resp.errorMessage))
}
}
false

View File

@@ -135,6 +135,7 @@ class NativeCallSpec extends Specification {
StepVerifier.create(resp)
.expectNext(BlockchainOuterClass.NativeCallReplyItem.newBuilder()
.setSucceed(false)
.setErrorMessage("Failed to call 5: test test")
.setId(5)
.build())
.expectComplete()
@@ -151,6 +152,7 @@ class NativeCallSpec extends Specification {
StepVerifier.create(resp)
.expectNext(BlockchainOuterClass.NativeCallReplyItem.newBuilder()
.setSucceed(false)
.setErrorMessage("test test")
.build())
.expectComplete()
.verify(Duration.ofSeconds(1))