diff --git a/DotNetDBF/DBFException.cs b/DotNetDBF/DBFException.cs
index ce3774f..426ed3c 100644
--- a/DotNetDBF/DBFException.cs
+++ b/DotNetDBF/DBFException.cs
@@ -28,6 +28,22 @@ public DBTException(String msg, Exception internalException)
{
}
}
+
+ public class DBFRecordException : DBFException
+ {
+ public int Record { get; }
+
+ public DBFRecordException(String msg, int record) : base(msg)
+ {
+ Record = record;
+ }
+
+ public DBFRecordException(String msg, Exception internalException)
+ : base(msg, internalException)
+ {
+ }
+ }
+
public class DBFException : IOException
{
public DBFException() : base()
diff --git a/DotNetDBF/DBFWriter.cs b/DotNetDBF/DBFWriter.cs
index 58f9519..a892d66 100644
--- a/DotNetDBF/DBFWriter.cs
+++ b/DotNetDBF/DBFWriter.cs
@@ -260,47 +260,41 @@ private void AddRecord(Object[] values, bool writeImediately)
case NativeDbType.Char:
if (!(values[i] is String) && !(values[i] is DBNull))
{
- throw new DBFException("Invalid value for field "
- + i);
+ throw new DBFRecordException($"Invalid value for field {i}", i);
}
break;
case NativeDbType.Logical:
if (!(values[i] is Boolean) && !(values[i] is DBNull))
{
- throw new DBFException("Invalid value for field "
- + i);
+ throw new DBFRecordException($"Invalid value for field {i}", i);
}
break;
case NativeDbType.Numeric:
if (!(values[i] is IConvertible) && !(values[i] is DBNull))
{
- throw new DBFException("Invalid value for field "
- + i);
+ throw new DBFRecordException($"Invalid value for field {i}", i);
}
break;
case NativeDbType.Date:
if (!(values[i] is DateTime) && !(values[i] is DBNull))
{
- throw new DBFException("Invalid value for field "
- + i);
+ throw new DBFRecordException($"Invalid value for field {i}", i);
}
break;
case NativeDbType.Float:
if (!(values[i] is IConvertible) && !(values[i] is DBNull))
{
- throw new DBFException("Invalid value for field "
- + i);
+ throw new DBFRecordException($"Invalid value for field {i}", i);
}
break;
case NativeDbType.Memo:
if (!(values[i] is MemoValue) && !(values[i] is DBNull))
{
- throw new DBFException("Invalid value for field "
- + i);
+ throw new DBFRecordException($"Invalid value for field {i}", i);
}
break;
}
diff --git a/DotNetDBF/DotNetDBF.csproj b/DotNetDBF/DotNetDBF.csproj
index 9b7e888..acb3ddd 100644
--- a/DotNetDBF/DotNetDBF.csproj
+++ b/DotNetDBF/DotNetDBF.csproj
@@ -3,9 +3,9 @@
net35;netstandard1.3
True
sn.snk
- 5.0.2.0
- 5.0.2.0
- 5.0.2.0
+ 5.0.3.0
+ 5.0.3.0
+ 5.0.3.0
Ekon Benefits
Copyright 2009-2017
This is a basic file parser for reading and writing xBase DBF files particularlly Clipper. Code originally derived from javadbf.