public RpcErrorExceptionInfo ConvertExceptionToErrorExceptionInfo(string databaseName, Exception ex) { RpcErrorExceptionInfo rpcErrorExceptionInfo = new RpcErrorExceptionInfo(); if (ex == null) { return(rpcErrorExceptionInfo); } TBaseException ex2 = ex as TBaseException; TBaseTransientException ex3 = ex as TBaseTransientException; string errorMessage; if (ex2 != null) { errorMessage = HaRpcExceptionWrapperBase <TBaseException, TBaseTransientException> .SetExceptionProperties <TBaseException>(ex2, true, databaseName); } else if (ex3 != null) { errorMessage = HaRpcExceptionWrapperBase <TBaseException, TBaseTransientException> .SetExceptionProperties <TBaseTransientException>(ex3, true, databaseName); } else { errorMessage = ex.ToString(); } rpcErrorExceptionInfo.ErrorMessage = errorMessage; rpcErrorExceptionInfo.ReconstitutedException = ex; HaRpcExceptionWrapperBase <TBaseException, TBaseTransientException> .TrySerializeException(ex, rpcErrorExceptionInfo); return(rpcErrorExceptionInfo); }
public void ClientRetryableOperation(string serverName, RpcClientOperation rpcOperation) { if (rpcOperation == null) { throw new ArgumentNullException("rpcOperation"); } string serverName2 = HaRpcExceptionWrapperBase <TBaseException, TBaseTransientException> .SanitizeServerName(serverName); int num = 0; int num2 = 0; int num3 = 0; bool flag; do { flag = false; try { rpcOperation(); } catch (RpcException ex) { if (this.ClientShouldRetryOnError(ex, serverName2, ref num, ref num2, ref num3)) { flag = true; } else { this.ClientHandleRpcException(ex, serverName2); } } }while (flag); }
public void ClientRethrowIfFailed(string databaseName, string serverName, RpcErrorExceptionInfo errorInfo) { Exception ex = null; string text = HaRpcExceptionWrapperBase <TBaseException, TBaseTransientException> .SanitizeServerName(serverName); if (errorInfo.IsFailed()) { if (errorInfo.ReconstitutedException != null) { ex = this.ConstructClientExceptionFromServerException(text, errorInfo.ReconstitutedException); } else { if (errorInfo.SerializedException != null && errorInfo.SerializedException.Length > 0) { try { errorInfo.ReconstitutedException = SerializationServices.Deserialize <Exception>(errorInfo.SerializedException); ex = this.ConstructClientExceptionFromServerException(text, errorInfo.ReconstitutedException); goto IL_109; } catch (SerializationException innerException) { ex = this.GetGenericOperationFailedException(errorInfo.ErrorMessage, innerException); ((TBaseException)((object)ex)).OriginatingServer = text; goto IL_109; } catch (TargetInvocationException innerException2) { ex = this.GetGenericOperationFailedException(errorInfo.ErrorMessage, innerException2); ((TBaseException)((object)ex)).OriginatingServer = text; goto IL_109; } } if (!string.IsNullOrEmpty(errorInfo.ErrorMessage)) { ex = this.GetGenericOperationFailedException(errorInfo.ErrorMessage); ((TBaseException)((object)ex)).OriginatingServer = text; } else { ex = this.GetGenericOperationFailedWithEcException(errorInfo.ErrorCode); ((TBaseException)((object)ex)).OriginatingServer = text; } } IL_109: IHaRpcServerBaseException ex2 = ex as IHaRpcServerBaseException; if (ex2 != null && string.IsNullOrEmpty(ex2.DatabaseName) && !string.IsNullOrEmpty(databaseName)) { ((IHaRpcServerBaseExceptionInternal)ex).DatabaseName = databaseName; } } if (ex != null) { throw ex; } }
private Exception ConstructClientExceptionFromServerException(string originatingServerName, Exception serverException) { TBaseException ex = serverException as TBaseException; TBaseTransientException ex2 = serverException as TBaseTransientException; if (ex == null && ex2 == null) { if (this.IsKnownException(serverException)) { return(serverException); } if (serverException is TransientException) { ex2 = this.GetGenericOperationFailedTransientException(serverException.Message, serverException); HaRpcExceptionWrapperBase <TBaseException, TBaseTransientException> .SetExceptionProperties <TBaseTransientException>(ex2, false, null); } else { ex = this.GetGenericOperationFailedException(serverException.Message, serverException); HaRpcExceptionWrapperBase <TBaseException, TBaseTransientException> .SetExceptionProperties <TBaseException>(ex, false, null); } } Exception result; if (ex != null) { result = ex; this.SetExceptionServerNameIfEmpty <TBaseException>(ex, originatingServerName); } else { result = ex2; this.SetExceptionServerNameIfEmpty <TBaseTransientException>(ex2, originatingServerName); } return(result); }