diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/glbImporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/glbImporter.cs
index a0d489672..ac3eabf2d 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/glbImporter.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/glbImporter.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
-using UnityEngine;
namespace UniGLTF
@@ -14,7 +13,7 @@ namespace UniGLTF
public static GlbChunkType ToChunkType(this string src)
{
- switch(src)
+ switch (src)
{
case "BIN":
return GlbChunkType.BIN;
@@ -53,27 +52,27 @@ namespace UniGLTF
//
if (bytes.Length < 12)
{
- throw new FormatException("not glb header");
+ throw new GlbParseException("glb header not found");
}
int pos = 0;
if (Encoding.ASCII.GetString(bytes, 0, 4) != GLB_MAGIC)
{
- throw new FormatException("invalid magic");
+ throw new GlbParseException("invalid magic");
}
pos += 4;
var version = BitConverter.ToUInt32(bytes, pos);
if (version != GLB_VERSION)
{
- throw new FormatException($"unknown version: {version}");
+ throw new GlbParseException($"unknown version: {version}");
}
pos += 4;
var totalLength = BitConverter.ToUInt32(bytes, pos);
if (bytes.Length < totalLength)
{
- throw new System.IO.EndOfStreamException($"Not enough size: {bytes.Length} < {totalLength}");
+ throw new GlbParseException($"not enough size: {bytes.Length} < {totalLength}");
}
pos += 4;
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFException.cs b/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFException.cs
index fde2faaf8..8522e2201 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFException.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/UniGLTFException.cs
@@ -14,4 +14,12 @@ namespace UniGLTF
public UniGLTFNotSupportedException(string fmt, params object[] args) : this(string.Format(fmt, args)) { }
public UniGLTFNotSupportedException(string msg) : base(msg) { }
}
+
+ ///
+ /// Exception in parse the glb header
+ ///
+ public class GlbParseException : UniGLTFException
+ {
+ public GlbParseException(string msg) : base(msg) { }
+ }
}
diff --git a/Assets/UniGLTF/Tests/UniGLTF/GlbParserTests.cs b/Assets/UniGLTF/Tests/UniGLTF/GlbParserTests.cs
index ae99dba8c..9c36ec786 100644
--- a/Assets/UniGLTF/Tests/UniGLTF/GlbParserTests.cs
+++ b/Assets/UniGLTF/Tests/UniGLTF/GlbParserTests.cs
@@ -66,7 +66,7 @@ namespace UniGLTF
// glb header + 1st chunk only
var mod = bytes.Take(12 + 8 + data.Chunks[0].Bytes.Count).ToArray();
- Assert.Throws(() =>
+ Assert.Throws(() =>
{
// 再パース
var data2 = new GlbBinaryParser(mod, Path.GetFileNameWithoutExtension(path)).Parse();