using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Sockets; using SuperSocket.SocketBase; namespace SuperSocket.SocketEngine { abstract partial class SocketSession { private const string m_GeneralErrorMessage = "Unexpected error"; private const string m_GeneralSocketErrorMessage = "Unexpected socket error: {0}"; /// /// Logs the error, skip the ignored exception /// /// The exception. protected void LogError(Exception exception) { int socketErrorCode; //This exception is ignored, needn't log it if (IsIgnorableException(exception, out socketErrorCode)) return; var message = socketErrorCode > 0 ? string.Format(m_GeneralSocketErrorMessage, socketErrorCode) : m_GeneralErrorMessage; AppSession.Logger.Error(this, message, exception); } /// /// Logs the error, skip the ignored exception /// /// The message. /// The exception. protected void LogError(string message, Exception exception) { int socketErrorCode; //This exception is ignored, needn't log it if (IsIgnorableException(exception, out socketErrorCode)) return; AppSession.Logger.Error(this, message, exception); } /// /// Logs the socket error, skip the ignored error /// /// The socket error code. protected void LogError(int socketErrorCode) { if (!Config.LogAllSocketException) { //This error is ignored, needn't log it if (IsIgnorableSocketError(socketErrorCode)) return; } AppSession.Logger.Error(this, string.Format(m_GeneralSocketErrorMessage, socketErrorCode), new SocketException(socketErrorCode)); } } }