forked from kerryjiang/SuperSocket
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocketSession.Net.cs
More file actions
64 lines (54 loc) · 2.13 KB
/
SocketSession.Net.cs
File metadata and controls
64 lines (54 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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}";
/// <summary>
/// Logs the error, skip the ignored exception
/// </summary>
/// <param name="exception">The exception.</param>
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(message, exception, this);
}
/// <summary>
/// Logs the error, skip the ignored exception
/// </summary>
/// <param name="message">The message.</param>
/// <param name="exception">The exception.</param>
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(message, exception, this);
}
/// <summary>
/// Logs the socket error, skip the ignored error
/// </summary>
/// <param name="socketErrorCode">The socket error code.</param>
protected void LogError(int socketErrorCode)
{
if (!Config.LogAllSocketException)
{
//This error is ignored, needn't log it
if (IsIgnorableSocketError(socketErrorCode))
return;
}
AppSession.Logger.Error(string.Format(m_GeneralSocketErrorMessage, socketErrorCode), new SocketException(socketErrorCode), this);
}
}
}