Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Been chewing on this for the last few days for some reason. I think the error message wasn't quite what I wanted it to be, so I wasn't ready to commit it to the repo just yet. I like this error message now, as it's more clear what happened, but also not overly-verbose, which is what I didn't like about the error messages I had made so far. This essentially checks if the `NBTReader`'s reading `#byteOffset` is longer than the source `Uint8Array`'s length, which would mean that it can't read any more data, since it's read up to the end of the buffer. This puts a little roadblock before showing any confusing `DataView` errors, which aren't as apparent as to what went wrong. These should help make things more visible to the user, if something is wrong with the data, or if they are reading in the wrong format. I'm gonna do some more testing after getting this initial version for these errors up, and maybe moving the error back a little bit, to where the `#byteOffset` is incremented to a value higher than the buffer length. This would make the error show up sooner while reading the data, as it would make the error-prone next read exclusive, rather than inclusive. In other words, instead of throwing the error when it tries to read at an il-formatted offset, it will throw when the offset is set to that il-formatted length. I just keep flip-flopping on how the errors should be (I seem to do this a lot with the JSDoc annotations too), so I have to commit something now, or else I'll just keep working on this derpy little fix forever, for some reason, aaah! XD
- Loading branch information