Skip to content

Commit 271b798

Browse files
authored
Merge pull request #349 from DataObjects-NET/6.0-improve-error-message
Improves error message when entity is removed
2 parents 9d7e411 + 66e32b7 commit 271b798

File tree

7 files changed

+14
-13
lines changed

7 files changed

+14
-13
lines changed

ChangeLog/6.0.12_dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[main] Addressed DataTypeCollection.Add method issue of wrong adding storage-specifid types to the collection
22
[main] Addressed rare issue of entities expire management when SessionOption.NonTransactionalReads is on
33
[main] Fixed issue of skipping persist or query tasks during batching
4+
[main] Improved error message when the entity user operates with is removed, now it contains type of entity
45
[sqlserver] Sql error messages for British English are correctly parsed

Orm/Xtensive.Orm.Tests/Storage/GeneralBehaviorTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private static void AssertEntityRemovalHasBeenDetected(Action action)
149149
action.Invoke();
150150
}
151151
catch (InvalidOperationException e) {
152-
Assert.AreEqual(Strings.ExEntityIsRemoved, e.Message);
152+
Assert.AreEqual(string.Format(Strings.ExEntityOfTypeXIsRemoved, nameof(Order)), e.Message);
153153
}
154154
}
155155
}

Orm/Xtensive.Orm/Orm/Entity.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ internal void RemoveInternal(EntityRemoveReason reason)
417417
internal void EnsureNotRemoved()
418418
{
419419
if (IsRemoved)
420-
throw new InvalidOperationException(Strings.ExEntityIsRemoved);
420+
throw new InvalidOperationException(string.Format(Strings.ExEntityOfTypeXIsRemoved, TypeInfo.Name));
421421
}
422422

423423
internal override sealed ValidationResult GetValidationResult()

Orm/Xtensive.Orm/Orm/EntitySetBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public bool Contains(Key key)
154154
protected void EnsureOwnerIsNotRemoved()
155155
{
156156
if (Owner.IsRemoved) {
157-
throw new InvalidOperationException(Strings.ExEntityIsRemoved);
157+
throw new InvalidOperationException(string.Format(Strings.ExEntityOfTypeXIsRemoved, Owner.TypeInfo.Name));
158158
}
159159
}
160160

Orm/Xtensive.Orm/Orm/Structure.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,12 @@ private bool InnerEquals(Structure other, bool thisIsBound, bool otherIsBound)
339339
if (thisIsBound) {
340340
EnsureIsFetched(Field);
341341
if (Entity.IsRemoved && !Session.Configuration.Supports(SessionOptions.ReadRemovedObjects))
342-
throw new InvalidOperationException(Strings.ExEntityIsRemoved);
342+
throw new InvalidOperationException(string.Format(Strings.ExEntityOfTypeXIsRemoved, Entity.TypeInfo.Name));
343343
}
344344
if (otherIsBound) {
345345
other.EnsureIsFetched(other.Field);
346346
if (other.Entity.IsRemoved && !Session.Configuration.Supports(SessionOptions.ReadRemovedObjects))
347-
throw new InvalidOperationException(Strings.ExEntityIsRemoved);
347+
throw new InvalidOperationException(string.Format(Strings.ExEntityOfTypeXIsRemoved, other.Entity.TypeInfo.Name));
348348
}
349349
return Equals(Tuple, other.Tuple);
350350
}

Orm/Xtensive.Orm/Strings.Designer.cs

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Orm/Xtensive.Orm/Strings.resx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1172,8 +1172,8 @@
11721172
<data name="ValueCanNotBeNull" xml:space="preserve">
11731173
<value>Value can not be null.</value>
11741174
</data>
1175-
<data name="ExEntityIsRemoved" xml:space="preserve">
1176-
<value>Entity is removed.</value>
1175+
<data name="ExEntityOfTypeXIsRemoved" xml:space="preserve">
1176+
<value>Entity of type '{0}' is removed.</value>
11771177
</data>
11781178
<data name="ValueLengthCanNotExceedX" xml:space="preserve">
11791179
<value>Value can not exceed {0}.</value>

0 commit comments

Comments
 (0)