增加报错信息

This commit is contained in:
ww-rm
2025-09-11 23:17:13 +08:00
parent 415df555c7
commit 9c0acf7302
11 changed files with 140 additions and 49 deletions

View File

@@ -30,8 +30,15 @@ namespace Spine.Implementations.SpineWrappers.V21
: base(skelPath, atlasPath, textureLoader) : base(skelPath, atlasPath, textureLoader)
{ {
// 加载 atlas // 加载 atlas
try { _atlas = new Atlas(atlasPath, textureLoader); } try
catch (Exception ex) { throw new InvalidDataException($"Failed to load atlas '{atlasPath}'", ex); } {
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
try try
{ {
@@ -41,8 +48,9 @@ namespace Spine.Implementations.SpineWrappers.V21
{ {
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -52,8 +60,9 @@ namespace Spine.Implementations.SpineWrappers.V21
{ {
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -61,7 +70,8 @@ namespace Spine.Implementations.SpineWrappers.V21
catch (Exception ex) catch (Exception ex)
{ {
_atlas.Dispose(); _atlas.Dispose();
throw new InvalidDataException($"Failed to load skeleton file {skelPath}", ex); _logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
} }
// 加载动画数据 // 加载动画数据

View File

@@ -30,8 +30,15 @@ namespace Spine.Implementations.SpineWrappers.V34
: base(skelPath, atlasPath, textureLoader) : base(skelPath, atlasPath, textureLoader)
{ {
// 加载 atlas // 加载 atlas
try { _atlas = new Atlas(atlasPath, textureLoader); } try
catch (Exception ex) { throw new InvalidDataException($"Failed to load atlas '{atlasPath}'", ex); } {
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
try try
{ {
@@ -41,8 +48,9 @@ namespace Spine.Implementations.SpineWrappers.V34
{ {
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -52,8 +60,9 @@ namespace Spine.Implementations.SpineWrappers.V34
{ {
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -61,7 +70,8 @@ namespace Spine.Implementations.SpineWrappers.V34
catch (Exception ex) catch (Exception ex)
{ {
_atlas.Dispose(); _atlas.Dispose();
throw new InvalidDataException($"Failed to load skeleton file {skelPath}", ex); _logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
} }
// 加载动画数据 // 加载动画数据

View File

@@ -30,8 +30,15 @@ namespace Spine.Implementations.SpineWrappers.V35
: base(skelPath, atlasPath, textureLoader) : base(skelPath, atlasPath, textureLoader)
{ {
// 加载 atlas // 加载 atlas
try { _atlas = new Atlas(atlasPath, textureLoader); } try
catch (Exception ex) { throw new InvalidDataException($"Failed to load atlas '{atlasPath}'", ex); } {
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
try try
{ {
@@ -41,8 +48,9 @@ namespace Spine.Implementations.SpineWrappers.V35
{ {
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -52,8 +60,9 @@ namespace Spine.Implementations.SpineWrappers.V35
{ {
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -61,7 +70,8 @@ namespace Spine.Implementations.SpineWrappers.V35
catch (Exception ex) catch (Exception ex)
{ {
_atlas.Dispose(); _atlas.Dispose();
throw new InvalidDataException($"Failed to load skeleton file {skelPath}", ex); _logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
} }
// 加载动画数据 // 加载动画数据

View File

@@ -30,8 +30,15 @@ namespace Spine.Implementations.SpineWrappers.V36
: base(skelPath, atlasPath, textureLoader) : base(skelPath, atlasPath, textureLoader)
{ {
// 加载 atlas // 加载 atlas
try { _atlas = new Atlas(atlasPath, textureLoader); } try
catch (Exception ex) { throw new InvalidDataException($"Failed to load atlas '{atlasPath}'", ex); } {
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
try try
{ {
@@ -41,8 +48,9 @@ namespace Spine.Implementations.SpineWrappers.V36
{ {
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -52,8 +60,9 @@ namespace Spine.Implementations.SpineWrappers.V36
{ {
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -61,7 +70,8 @@ namespace Spine.Implementations.SpineWrappers.V36
catch (Exception ex) catch (Exception ex)
{ {
_atlas.Dispose(); _atlas.Dispose();
throw new InvalidDataException($"Failed to load skeleton file {skelPath}", ex); _logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
} }
// 加载动画数据 // 加载动画数据

View File

@@ -30,8 +30,15 @@ namespace Spine.Implementations.SpineWrappers.V37
: base(skelPath, atlasPath, textureLoader) : base(skelPath, atlasPath, textureLoader)
{ {
// 加载 atlas // 加载 atlas
try { _atlas = new Atlas(atlasPath, textureLoader); } try
catch (Exception ex) { throw new InvalidDataException($"Failed to load atlas '{atlasPath}'", ex); } {
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
try try
{ {
@@ -41,8 +48,9 @@ namespace Spine.Implementations.SpineWrappers.V37
{ {
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -52,8 +60,9 @@ namespace Spine.Implementations.SpineWrappers.V37
{ {
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -61,7 +70,8 @@ namespace Spine.Implementations.SpineWrappers.V37
catch (Exception ex) catch (Exception ex)
{ {
_atlas.Dispose(); _atlas.Dispose();
throw new InvalidDataException($"Failed to load skeleton file {skelPath}", ex); _logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
} }
// 加载动画数据 // 加载动画数据

View File

@@ -31,8 +31,15 @@ namespace Spine.Implementations.SpineWrappers.V38
: base(skelPath, atlasPath, textureLoader) : base(skelPath, atlasPath, textureLoader)
{ {
// 加载 atlas // 加载 atlas
try { _atlas = new Atlas(atlasPath, textureLoader); } try
catch (Exception ex) { throw new InvalidDataException($"Failed to load atlas '{atlasPath}'", ex); } {
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
try try
{ {
@@ -42,8 +49,9 @@ namespace Spine.Implementations.SpineWrappers.V38
{ {
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -53,8 +61,9 @@ namespace Spine.Implementations.SpineWrappers.V38
{ {
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -62,7 +71,8 @@ namespace Spine.Implementations.SpineWrappers.V38
catch (Exception ex) catch (Exception ex)
{ {
_atlas.Dispose(); _atlas.Dispose();
throw new InvalidDataException($"Failed to load skeleton file {skelPath}", ex); _logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
} }
// 加载动画数据 // 加载动画数据

View File

@@ -30,10 +30,16 @@ namespace Spine.Implementations.SpineWrappers.V40
: base(skelPath, atlasPath, textureLoader) : base(skelPath, atlasPath, textureLoader)
{ {
// 加载 atlas // 加载 atlas
try { _atlas = new Atlas(atlasPath, textureLoader); } try
catch (Exception ex) { throw new InvalidDataException($"Failed to load atlas '{atlasPath}'", ex); } {
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
// 加载 skel
try try
{ {
if (Utf8Validator.IsUtf8(skelPath)) if (Utf8Validator.IsUtf8(skelPath))
@@ -42,8 +48,9 @@ namespace Spine.Implementations.SpineWrappers.V40
{ {
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -53,8 +60,9 @@ namespace Spine.Implementations.SpineWrappers.V40
{ {
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -62,7 +70,8 @@ namespace Spine.Implementations.SpineWrappers.V40
catch (Exception ex) catch (Exception ex)
{ {
_atlas.Dispose(); _atlas.Dispose();
throw new InvalidDataException($"Failed to load skeleton file {skelPath}", ex); _logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
} }
// 加载动画数据 // 加载动画数据

View File

@@ -30,10 +30,16 @@ namespace Spine.Implementations.SpineWrappers.V41
: base(skelPath, atlasPath, textureLoader) : base(skelPath, atlasPath, textureLoader)
{ {
// 加载 atlas // 加载 atlas
try { _atlas = new Atlas(atlasPath, textureLoader); } try
catch (Exception ex) { throw new InvalidDataException($"Failed to load atlas '{atlasPath}'", ex); } {
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
// 加载 skel
try try
{ {
if (Utf8Validator.IsUtf8(skelPath)) if (Utf8Validator.IsUtf8(skelPath))
@@ -42,8 +48,9 @@ namespace Spine.Implementations.SpineWrappers.V41
{ {
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -53,8 +60,9 @@ namespace Spine.Implementations.SpineWrappers.V41
{ {
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -62,7 +70,8 @@ namespace Spine.Implementations.SpineWrappers.V41
catch (Exception ex) catch (Exception ex)
{ {
_atlas.Dispose(); _atlas.Dispose();
throw new InvalidDataException($"Failed to load skeleton file {skelPath}", ex); _logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
} }
// 加载动画数据 // 加载动画数据

View File

@@ -30,10 +30,16 @@ namespace Spine.Implementations.SpineWrappers.V42
: base(skelPath, atlasPath, textureLoader) : base(skelPath, atlasPath, textureLoader)
{ {
// 加载 atlas // 加载 atlas
try { _atlas = new Atlas(atlasPath, textureLoader); } try
catch (Exception ex) { throw new InvalidDataException($"Failed to load atlas '{atlasPath}'", ex); } {
_atlas = new Atlas(atlasPath, textureLoader);
}
catch (Exception ex)
{
_logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load atlas '{atlasPath}'");
}
// 加载 skel
try try
{ {
if (Utf8Validator.IsUtf8(skelPath)) if (Utf8Validator.IsUtf8(skelPath))
@@ -42,8 +48,9 @@ namespace Spine.Implementations.SpineWrappers.V42
{ {
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -53,8 +60,9 @@ namespace Spine.Implementations.SpineWrappers.V42
{ {
_skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonBinary(_atlas).ReadSkeletonData(skelPath);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
_skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath); _skeletonData = new SkeletonJson(_atlas).ReadSkeletonData(skelPath);
} }
} }
@@ -62,7 +70,8 @@ namespace Spine.Implementations.SpineWrappers.V42
catch (Exception ex) catch (Exception ex)
{ {
_atlas.Dispose(); _atlas.Dispose();
throw new InvalidDataException($"Failed to load skeleton file {skelPath}", ex); _logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load skeleton file {skelPath}");
} }
// 加载动画数据 // 加载动画数据

View File

@@ -115,8 +115,9 @@ namespace Spine
{ {
_data = SpineObjectData.New(Version, skelPath, atlasPath, textureLoader); _data = SpineObjectData.New(Version, skelPath, atlasPath, textureLoader);
} }
catch catch (Exception ex)
{ {
_logger.Trace(ex.ToString());
throw new InvalidDataException($"Failed to load spine with version '{version}'"); throw new InvalidDataException($"Failed to load spine with version '{version}'");
} }
} }

View File

@@ -5,6 +5,7 @@ using System.Collections.Immutable;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NLog;
using Spine.SpineWrappers.Attachments; using Spine.SpineWrappers.Attachments;
namespace Spine.SpineWrappers namespace Spine.SpineWrappers
@@ -17,6 +18,8 @@ namespace Spine.SpineWrappers
ISpineObjectData, ISpineObjectData,
IDisposable IDisposable
{ {
protected static readonly Logger _logger = LogManager.GetCurrentClassLogger();
/// <summary> /// <summary>
/// 构建版本对象 /// 构建版本对象
/// </summary> /// </summary>