From d70668d11d1e483bbb48330d49f1d7550b73bc4c Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Wed, 12 Aug 2020 15:05:10 -0700 Subject: [PATCH] Added InvalidFormat Added deprecated constructor for InvalidFormat with a null ByteInput for temp back compat --- core/src/com/riiablo/io/InvalidFormat.java | 28 +++++++++++++++++++ core/src/com/riiablo/item/ItemSerializer.java | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 core/src/com/riiablo/io/InvalidFormat.java diff --git a/core/src/com/riiablo/io/InvalidFormat.java b/core/src/com/riiablo/io/InvalidFormat.java new file mode 100644 index 00000000..0f38d4bc --- /dev/null +++ b/core/src/com/riiablo/io/InvalidFormat.java @@ -0,0 +1,28 @@ +package com.riiablo.io; + +public class InvalidFormat extends RuntimeException { + public final long offset; + + public InvalidFormat(ByteInput in, String message) { + this(in, message, null); + } + + public InvalidFormat(ByteInput in, Throwable cause) { + this(in, "Invalid format", cause); + } + + public InvalidFormat(ByteInput in, String message, Throwable cause) { + super(message + " @0x" + Integer.toHexString(in.bytesRead()), cause); + this.offset = in.bytesRead(); + } + + @Deprecated + public InvalidFormat(String message) { + super(message, null); + this.offset = 0L; + } + + public long offset() { + return offset; + } +} diff --git a/core/src/com/riiablo/item/ItemSerializer.java b/core/src/com/riiablo/item/ItemSerializer.java index 5065b3c8..40f8668f 100644 --- a/core/src/com/riiablo/item/ItemSerializer.java +++ b/core/src/com/riiablo/item/ItemSerializer.java @@ -8,9 +8,9 @@ import com.badlogic.gdx.utils.Array; import com.riiablo.Riiablo; import com.riiablo.codec.excel.Gems; import com.riiablo.codec.util.BitStream; +import com.riiablo.io.InvalidFormat; import com.riiablo.log.Log; import com.riiablo.log.LogManager; -import com.riiablo.save.InvalidFormat; import com.riiablo.util.DebugUtils; public class ItemSerializer {