Error message improved in LoadById

main
Inga 🏳‍🌈 15 years ago
parent 591cc365a2
commit e0f00a7112
  1. 2
      Core/DB/IDBConnection.cs
  2. 2
      Core/exceptions/NotFoundInDBException.cs

@ -47,7 +47,7 @@ namespace FLocal.Core.DB {
public static Dictionary<string, string> LoadById(this IDBConnection connection, ITableSpec table, string id) { public static Dictionary<string, string> LoadById(this IDBConnection connection, ITableSpec table, string id) {
List<Dictionary<string, string>> rows = connection.LoadByIds(table, new List<string> { id }); List<Dictionary<string, string>> rows = connection.LoadByIds(table, new List<string> { id });
if(rows.Count < 1) { if(rows.Count < 1) {
throw new NotFoundInDBException(); throw new NotFoundInDBException(table, id);
} }
if(rows.Count > 1) { if(rows.Count > 1) {
throw new CriticalException(rows.Count + " objects with specified id"); throw new CriticalException(rows.Count + " objects with specified id");

@ -9,6 +9,8 @@ namespace FLocal.Core {
public NotFoundInDBException() : base("Object not found in DB") { } public NotFoundInDBException() : base("Object not found in DB") { }
public NotFoundInDBException(DB.ITableSpec tableSpec, string id) : base("Object " + tableSpec.name + "[" + tableSpec.idName + "=" + id + "] not found in db") {}
} }
} }

Loading…
Cancel
Save