diff --git a/Server/Protocol/Packet.cs b/Server/Protocol/Packet.cs
index 257c04d..97ff7b1 100644
--- a/Server/Protocol/Packet.cs
+++ b/Server/Protocol/Packet.cs
@@ -30,17 +30,4 @@ namespace PSO2SERVER.Protocol
return totalPacket.ToArray(); // 返回整个数据包字节数组
}
}
-
- public class PacketError : Exception
- {
- public string PacketName { get; }
- public string FieldName { get; }
-
- public PacketError(string packetName, string fieldName, Exception innerException)
- : base($"Error in packet '{packetName}', field '{fieldName}'", innerException)
- {
- PacketName = packetName;
- FieldName = fieldName;
- }
- }
}
\ No newline at end of file
diff --git a/Server/Protocol/PacketError.cs b/Server/Protocol/PacketError.cs
new file mode 100644
index 0000000..1c7f1d0
--- /dev/null
+++ b/Server/Protocol/PacketError.cs
@@ -0,0 +1,76 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PSO2SERVER.Protocol
+{
+ public class PacketError : Exception
+ {
+ public string PacketName { get; }
+ public string FieldName { get; }
+ public long ConstantValue { get; }
+ public Exception InnerError { get; }
+
+ // 构造函数: 读取/写入字段失败
+ public PacketError(string packetName, string fieldName, Exception error)
+ : base($"读取/写入字段 {fieldName} 来自 {packetName} 时发生错误: {error.Message}", error)
+ {
+ PacketName = packetName;
+ FieldName = fieldName;
+ InnerError = error;
+ }
+
+ // 构造函数: 读取/写入标志或枚举值失败
+ public PacketError(string packetName, Exception error)
+ : base($"读取/写入 {packetName} 的值时发生错误: {error.Message}", error)
+ {
+ PacketName = packetName;
+ InnerError = error;
+ }
+
+ // 构造函数: 读取/写入字段长度失败
+ public PacketError(string packetName, string fieldName, Exception error, bool isFieldLengthError)
+ : base($"读取/写入字段 {fieldName} 来自 {packetName} 的长度时发生错误: {error.Message}", error)
+ {
+ PacketName = packetName;
+ FieldName = fieldName;
+ InnerError = error;
+ }
+
+ // 构造函数: 读取/写入组合字段失败
+ public PacketError(string packetName, string fieldName, PacketError innerError)
+ : base($"读取/写入组合字段 {fieldName} 来自 {packetName} 时发生错误: {innerError.Message}", innerError)
+ {
+ PacketName = packetName;
+ FieldName = fieldName;
+ InnerError = innerError;
+ }
+
+ // 构造函数: 填充字段时发生错误
+ public PacketError(string packetName, string fieldName, Exception error, int isPaddingError)
+ : base($"填充字段 {fieldName} 来自 {packetName} 时发生错误: {error.Message}", error)
+ {
+ PacketName = packetName;
+ FieldName = fieldName;
+ InnerError = error;
+ }
+
+ // 构造函数: 读取/写入常量值时发生错误
+ public PacketError(string packetName, long constantValue, Exception error)
+ : base($"读取/写入常量 {constantValue} 来自 {packetName} 时发生错误: {error.Message}", error)
+ {
+ PacketName = packetName;
+ ConstantValue = constantValue;
+ InnerError = error;
+ }
+
+ // 构造函数: 读取/写入数据包长度时发生错误
+ public PacketError(Exception error)
+ : base($"读取/写入数据包长度时发生错误: {error.Message}", error)
+ {
+ InnerError = error;
+ }
+ }
+}
diff --git a/Server/Server.csproj b/Server/Server.csproj
index 2104d07..b1ee86d 100644
--- a/Server/Server.csproj
+++ b/Server/Server.csproj
@@ -419,6 +419,7 @@
+