mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-10-24 14:05:42 +00:00
Simplify some exception throwing logic
This commit is contained in:
1 parent
959030f404
commit
c191639a24
5 files changed
+6
-31
No files matched your search
@@ -34,11 +34,7 @@ namespace EightBit
|
||||
ArgumentNullException.ThrowIfNullOrEmpty(line);
|
||||
|
||||
var requiredLength = 9 + 2 + (count * 2);
|
||||
if (line.Length != requiredLength)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(line), "Invalid hex file: line is not the required length");
|
||||
}
|
||||
|
||||
ArgumentOutOfRangeException.ThrowIfNotEqual(line.Length, requiredLength, nameof(line));
|
||||
var data = new byte[count];
|
||||
for (var i = 0; i < count; ++i)
|
||||
{
|
||||
@@ -55,10 +51,7 @@ namespace EightBit
|
||||
ArgumentNullException.ThrowIfNullOrEmpty(line);
|
||||
|
||||
var colon = line[..1];
|
||||
if (colon != ":")
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(line), "Invalid hex file: line does not begin with a colon");
|
||||
}
|
||||
ArgumentOutOfRangeException.ThrowIfNotEqual(colon, ":", nameof(line));
|
||||
|
||||
var countString = line.Substring(1, 2);
|
||||
var count = Convert.ToByte(countString, 16);
|
||||
|
||||
Reference in new issue
Block a user