/// <summary> /// Enables the creation of a custom <see cref="FaultException{TDetail}"/> that is returned from an exception in the course of a service method. /// </summary> /// <param name="error">The <see cref="Exception"/> object thrown in the course of the service operation.</param> /// <param name="version">The SOAP version of the message.</param> /// <param name="fault">The <see cref="Message"/> object that is returned to the client, or service, in the duplex case.</param> public void ProvideFault(Exception error, MessageVersion version, ref Message fault) { FaultException e; SqlException se = error as SqlException; if (se == null) { EntityException ee = error as EntityException; if (ee != null) { se = ee.InnerException as SqlException; } } if (se != null && se.IsOfflineException()) { e = new FaultException <OfflineDataException>(new OfflineDataException(se), new FaultReason(se.Message)); } else { FaultException <OfflineDataException> fe = error as FaultException <OfflineDataException>; if (fe != null) { e = fe; } else { e = new FaultException <Exception>(error, error.Message); } } fault = Message.CreateMessage(version, e.CreateMessageFault(), e.Action); }
/// <summary> /// Logs an exception. /// </summary> /// <param name="e">The exception to log.</param> /// <returns>true if a rethrow is recommended; otherwise, false.</returns> public static bool LogException(Exception e) { SqlException se = e as SqlException; if (se != null && !se.IsOfflineException()) // only log non-offline exceptions { return(ExceptionPolicy.HandleException(e, _settings.LogOnlyPolicyName)); } else { return(false); } }