Ejemplo n.º 1
0
 /// <summary>
 /// Constructor. Use this when the state is related to an error.
 /// </summary>
 /// <param name="connMaint">Whether the connection is being maintained or at least attempted.</param>
 /// <param name="evType">Current state of connection.</param>
 /// <param name="desc">Event description.</param>
 /// <param name="errReason">Error reason.</param>
 /// <param name="excep">Exception related to the error.</param>
 public ConnectionEvent(bool connMaint, ConnectionEventType evType, string desc, ErrorReasonType errReason, Exception excep)
 {
     IsConnectionMaintained = connMaint;
     EventType        = evType;
     Description      = desc;
     ErrorReason      = errReason;
     RelatedException = excep;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a connection-related error to the log.
        /// </summary>
        /// <param name="reason">Suspected reason.</param>
        /// <param name="ex">Exception.</param>
        public void AddConnectionError(ErrorReasonType reason, Exception ex)
        {
            // 1) Add to event log
            try
            {
                var msg = string.Format("Failed to connect, suspected reason: {0}; {1}",
                                        reason.ToString(),
                                        ex.Message
                                        );
                AddConnectionEvent(msg); // throws InvalidOperationException
            }
            catch (Exception e)
            {
                AddExceptionToLog(e); // No exceptions are leaked from logger
            }

            // 2) Add to exception log
            AddExceptionToLog(ex); // No exceptions are leaked from logger
        }