@@ -136,6 +136,8 @@ module Server =
136136 raise <| ServerTimedOutException( exMsg, httpReqEx)
137137 if HttpRequestExceptionMatchesErrorCode httpReqEx ( int CloudFlareError.OriginUnreachable) then
138138 raise <| ServerTimedOutException( exMsg, httpReqEx)
139+ if HttpRequestExceptionMatchesErrorCode httpReqEx ( int HttpStatusCode.RequestTimeout) then
140+ raise <| ServerTimedOutException( exMsg, httpReqEx)
139141
140142 if HttpRequestExceptionMatchesErrorCode httpReqEx ( int CloudFlareError.OriginSslHandshakeError) then
141143 raise <| ServerChannelNegotiationException( exMsg, CloudFlareError.OriginSslHandshakeError, httpReqEx)
@@ -163,6 +165,8 @@ module Server =
163165 raise <| ServerUnavailableException( exMsg, httpReqEx)
164166 if HttpRequestExceptionMatchesErrorCode httpReqEx ( int HttpStatusCode.NotFound) then
165167 raise <| ServerUnavailableException( exMsg, httpReqEx)
168+ if HttpRequestExceptionMatchesErrorCode httpReqEx ( int HttpStatusCode.Gone) then
169+ raise <| ServerUnavailableException( exMsg, httpReqEx)
166170
167171 // this happened once with ETC (www.ethercluster.com/etc) when trying to broadcast a transaction
168172 // (not sure if it's correct to ignore it but I can't fathom how the tx could be a bad request:
@@ -234,6 +238,8 @@ module Server =
234238 raise <| ServerMisconfiguredException( exMsg, rpcResponseEx)
235239 | i when i = int RpcErrorCode.InternalError ->
236240 raise <| ServerFaultException( exMsg, rpcResponseEx)
241+ | j when j = int RpcErrorCode.UnparsableResponseType ->
242+ raise <| ServerFaultException( exMsg, rpcResponseEx)
237243 | _ ->
238244 raise
239245 <| Exception ( SPrintF3 " RpcResponseException with RpcError Code <%i > and Message '%s ' (%s )"
@@ -482,7 +488,10 @@ module Server =
482488 let! cancelToken = Async.CancellationToken
483489 let task =
484490 web3.Eth.Transactions.GetTransactionCount.SendRequestAsync( address, null , cancelToken)
485- return ! Async.AwaitTask task
491+ let! txCount = Async.AwaitTask task
492+ if isNull txCount then
493+ raise <| AbnormalNullValueInJsonResponseException " Abnormal null response from tx count job"
494+ return txCount
486495 }
487496 GetRandomizedFuncs currency web3Func
488497 return ! faultTolerantEtherClient.Query
@@ -498,7 +507,7 @@ module Server =
498507 web3.Eth.Blocks.GetBlockNumber.SendRequestAsync ( null , cancelToken)
499508 |> Async.AwaitTask
500509 if isNull latestBlock then
501- failwith " latestBlock somehow is null"
510+ raise <| AbnormalNullValueInJsonResponseException " latestBlock somehow is null"
502511
503512 let blockToCheck = BigInteger.Subtract( latestBlock.Value,
504513 NUMBER_ OF_ CONFIRMATIONS_ TO_ CONSIDER_ BALANCE_ CONFIRMED)
@@ -560,8 +569,10 @@ module Server =
560569 let task = web3.Eth.GetBalance.SendRequestAsync ( address, null , cancelToken)
561570 return ! Async.AwaitTask task
562571 }
563- if Object.ReferenceEquals( balance, null ) then
564- failwith " Weird null response from balance job"
572+ if isNull balance then
573+ raise <|
574+ AbnormalNullValueInJsonResponseException
575+ AbnormalNullValueInJsonResponseException.BalanceJobErrorMessage
565576 return UnitConversion.Convert.FromWei( balance.Value, UnitConversion.EthUnit.Ether)
566577 }
567578 GetRandomizedFuncs currency web3Func
@@ -591,7 +602,7 @@ module Server =
591602
592603 let contractHandler = web3.Eth.GetContractHandler contractAddress
593604 if isNull contractHandler then
594- failwith " contractHandler somehow is null"
605+ raise <| AbnormalNullValueInJsonResponseException " contractHandler somehow is null"
595606
596607 let! cancelToken = Async.CancellationToken
597608 cancelToken.ThrowIfCancellationRequested()
@@ -653,7 +664,10 @@ module Server =
653664 let! cancelToken = Async.CancellationToken
654665 let task =
655666 contractHandler.EstimateGasAsync< TransferFunction>( transferFunctionMsg, cancelToken)
656- return ! Async.AwaitTask task
667+ let! fee = Async.AwaitTask task
668+ if isNull fee then
669+ raise <| AbnormalNullValueInJsonResponseException " Abnormal null response from transfer fee job"
670+ return fee
657671 }
658672 GetRandomizedFuncs account.Currency web3Func
659673 return ! faultTolerantEtherClient.Query
@@ -676,6 +690,8 @@ module Server =
676690 let! cancelToken = Async.CancellationToken
677691 let task = web3.Eth.GasPrice.SendRequestAsync( null , cancelToken)
678692 let! hexBigInteger = Async.AwaitTask task
693+ if isNull hexBigInteger then
694+ raise <| AbnormalNullValueInJsonResponseException " Abnormal null response from gas price job"
679695 if hexBigInteger.Value = BigInteger 0 then
680696 return failwith " Some server returned zero for gas price, which is invalid"
681697 return hexBigInteger
@@ -706,7 +722,12 @@ module Server =
706722 let! cancelToken = Async.CancellationToken
707723 let task =
708724 web3.Eth.Transactions.SendRawTransaction.SendRequestAsync( transaction, null , cancelToken)
709- return ! Async.AwaitTask task
725+ let! response = Async.AwaitTask task
726+ if isNull response then
727+ raise <|
728+ AbnormalNullValueInJsonResponseException
729+ " Abnormal null response from broadcast transaction job"
730+ return response
710731 }
711732 GetRandomizedFuncs currency web3Func
712733 try
@@ -737,6 +758,10 @@ module Server =
737758 let task =
738759 web3.TransactionManager.TransactionReceiptService.PollForReceiptAsync( txHash, cancelToken)
739760 let! transactionReceipt = Async.AwaitTask task
761+ if isNull transactionReceipt || isNull transactionReceipt.GasUsed || isNull transactionReceipt.Status then
762+ raise <|
763+ AbnormalNullValueInJsonResponseException
764+ ( SPrintF1 " Abnormal null response when getting details from tx receipt (%A )" transactionReceipt)
740765 return {
741766 GasUsed = transactionReceipt.GasUsed.Value
742767 Status = transactionReceipt.Status.Value
0 commit comments