Skip to content

Commit

Permalink
Improve exception messages (#22511)
Browse files Browse the repository at this point in the history
Part of #7201
  • Loading branch information
smitpatel committed Sep 14, 2020
1 parent 56c241b commit e96b1a2
Show file tree
Hide file tree
Showing 51 changed files with 328 additions and 425 deletions.
32 changes: 16 additions & 16 deletions src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions src/EFCore.Cosmos/Properties/CosmosStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,16 @@
<value>The type of the '{idProperty}' property on '{entityType}' is '{propertyType}'. All 'id' properties need to be strings or have a string converter.</value>
</data>
<data name="InvalidDerivedTypeInEntityProjection" xml:space="preserve">
<value>'UpdateEntityType' called with '{derivedType}' which is not derived type of '{entityType}'.</value>
<value>The specified entity type '{derivedType}' is not derived from '{entityType}'.</value>
</data>
<data name="InvalidResourceId" xml:space="preserve">
<value>Invalid 'id' value. Supply a string value that's not null or empty.</value>
<value>Unable to generate a valid 'id' value to execute ReadItem query. This usually happens when value provided for one of the properties is null or empty string. Please supply a value that's not null or empty.</value>
</data>
<data name="JsonPropertyCollision" xml:space="preserve">
<value>Both properties '{property1}' and '{property2}' on entity type '{entityType}' are mapped to '{storeName}'. Map one of the properties to a different JSON property.</value>
</data>
<data name="MissingOrderingInSqlExpression" xml:space="preserve">
<value>Reverse could not be translated to the server because there is no ordering on the server side.</value>
<data name="MissingOrderingInSelectExpression" xml:space="preserve">
<value>'Reverse' could not be translated to the server because there is no ordering on the server side.</value>
</data>
<data name="NavigationPropertyIsNotAnEmbeddedEntity" xml:space="preserve">
<value>Navigation '{entityType}.{navigationName}' doesn't point to an embedded entity.</value>
Expand All @@ -160,7 +160,7 @@
<value>The entity type '{entityType}' does not have a property mapped to the 'id' property in the database. Add a property mapped as 'id'.</value>
</data>
<data name="NonEmbeddedIncludeNotSupported" xml:space="preserve">
<value>Non-embedded IncludeExpression is not supported: {expression}</value>
<value>Including navigation '{navigation}' is not supported as the navigation is not embedded in same resource.</value>
</data>
<data name="NonETagConcurrencyToken" xml:space="preserve">
<value>The entity type '{entityType}' has property '{property}' as its concurrency token, but only '_etag' is supported. Consider using 'EntityTypeBuilder.UseETagConcurrency'.</value>
Expand All @@ -178,7 +178,7 @@
<value>Expression '{sqlExpression}' in SQL tree does not have type mapping assigned.</value>
</data>
<data name="OffsetRequiresLimit" xml:space="preserve">
<value>Offset is not supported without Limit.</value>
<value>Cosmos SQL does not allow Offset without Limit. Consider specifying 'Take' operation on the query.</value>
</data>
<data name="OrphanedNestedDocument" xml:space="preserve">
<value>The entity of type '{entityType}' is mapped as a part of the document mapped to '{missingEntityType}', but there is no tracked entity of this type with the corresponding key value. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the key values.</value>
Expand All @@ -187,7 +187,7 @@
<value>The entity of type '{entityType}' is mapped as a part of the document mapped to '{missingEntityType}', but there is no tracked entity of this type with the key value '{keyValue}'.</value>
</data>
<data name="ParitionKeyMissing" xml:space="preserve">
<value>A ReadItem query was detected, but the partition key value is missing.</value>
<value>Unable to execute a ReadItem query since the partition key value is missing. Consider using 'WithPartitionKey' method on the query to specify partition key to use.</value>
</data>
<data name="PartitionKeyMismatch" xml:space="preserve">
<value>Partition key specified in the WithPartitionKey call '{paritionKey1}' and the partition key specified in the Where predicate '{paritionKey2}' must be identical. Remove one of them .</value>
Expand All @@ -202,10 +202,10 @@
<value>The partition key property '{property1}' on '{entityType1}' is mapped as '{storeName1}', but the partition key property '{property2}' on '{entityType2}' is mapped as '{storeName2}'. All partition key properties need to be mapped to the same store property.</value>
</data>
<data name="ResourceIdMissing" xml:space="preserve">
<value>A ReadItem query was detected, but the 'id' value is missing and cannot be generated.</value>
<value>Unable to execute a ReadItem query since the 'id' value is missing and cannot be generated.</value>
</data>
<data name="ReverseRequiresOffsetOrLimit" xml:space="preserve">
<value>Reverse is not supported without Limit or Offset.</value>
<data name="ReverseAfterSkipTakeNotSupported" xml:space="preserve">
<value>Reversing the ordering in 'SelectExpression' is not supported when limit or offset are already applied.</value>
</data>
<data name="UnableToBindMemberToEntityProjection" xml:space="preserve">
<value>Unable to bind '{memberType}' '{member}' to entity projection of '{entityType}'.</value>
Expand All @@ -217,6 +217,6 @@
<value>Conflicts were detected for item with id '{itemId}'.</value>
</data>
<data name="VisitChildrenMustBeOverridden" xml:space="preserve">
<value>VisitChildren must be overridden in class deriving from SqlExpression.</value>
<value>'VisitChildren' must be overridden in the class deriving from 'SqlExpression'.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ protected override Expression VisitExtension(Expression extensionExpression)
if (!(includeExpression.Navigation is INavigation includableNavigation
&& includableNavigation.IsEmbedded()))
{
throw new InvalidOperationException(CosmosStrings.NonEmbeddedIncludeNotSupported(includeExpression.Print()));
throw new InvalidOperationException(
CosmosStrings.NonEmbeddedIncludeNotSupported(includeExpression.Navigation));
}

_includedNavigations.Push(includableNavigation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ protected override ShapedQueryExpression TranslateReverse(ShapedQueryExpression
var selectExpression = (SelectExpression)source.QueryExpression;
if (selectExpression.Orderings.Count == 0)
{
AddTranslationErrorDetails(CosmosStrings.MissingOrderingInSqlExpression);
AddTranslationErrorDetails(CosmosStrings.MissingOrderingInSelectExpression);
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
|| navigation.IsOnDependent
|| navigation.ForeignKey.DeclaringEntityType.IsDocumentRoot())
{
throw new InvalidOperationException(CosmosStrings.NonEmbeddedIncludeNotSupported(includeExpression.Print()));
throw new InvalidOperationException(
CosmosStrings.NonEmbeddedIncludeNotSupported(includeExpression.Navigation));
}

_pendingIncludes.Add(includeExpression);
Expand Down Expand Up @@ -296,7 +297,8 @@ protected override Expression VisitExtension(Expression extensionExpression)
|| navigation.IsOnDependent
|| navigation.ForeignKey.DeclaringEntityType.IsDocumentRoot())
{
throw new InvalidOperationException(CosmosStrings.NonEmbeddedIncludeNotSupported(includeExpression.Print()));
throw new InvalidOperationException(
CosmosStrings.NonEmbeddedIncludeNotSupported(includeExpression.Navigation));
}

var isFirstInclude = _pendingIncludes.Count == 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public virtual Expression BindProperty([NotNull] IProperty property, bool client
&& !property.DeclaringEntityType.IsAssignableFrom(EntityType))
{
throw new InvalidOperationException(
CosmosStrings.UnableToBindMemberToEntityProjection("Property", property.Name, EntityType.DisplayName()));
CosmosStrings.UnableToBindMemberToEntityProjection("property", property.Name, EntityType.DisplayName()));
}

if (!_propertyExpressionsMap.TryGetValue(property, out var expression))
Expand All @@ -130,7 +130,7 @@ public virtual Expression BindProperty([NotNull] IProperty property, bool client
}

if (!clientEval
// TODO: Remove once __jObject is translated to the access root in a better fashion and
// TODO: Remove once __jObject is translated to the access root in a better fashion and
// would not otherwise be found to be non-translatable. See issues #17670 and #14121.
&& property.Name != StoreKeyConvention.JObjectPropertyName
&& expression.Name.Length == 0)
Expand All @@ -154,7 +154,7 @@ public virtual Expression BindNavigation([NotNull] INavigation navigation, bool
&& !navigation.DeclaringEntityType.IsAssignableFrom(EntityType))
{
throw new InvalidOperationException(
CosmosStrings.UnableToBindMemberToEntityProjection("Navigation", navigation.Name, EntityType.DisplayName()));
CosmosStrings.UnableToBindMemberToEntityProjection("navigation", navigation.Name, EntityType.DisplayName()));
}

if (!_navigationExpressionsMap.TryGetValue(navigation, out var expression))
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore.Cosmos/Query/Internal/SelectExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public virtual void ReverseOrderings()
if (Limit != null
|| Offset != null)
{
throw new InvalidOperationException(CosmosStrings.ReverseRequiresOffsetOrLimit);
throw new InvalidOperationException(CosmosStrings.ReverseAfterSkipTakeNotSupported);
}

var existingOrderings = _orderings.ToArray();
Expand Down
12 changes: 2 additions & 10 deletions src/EFCore.InMemory/Properties/InMemoryStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions src/EFCore.InMemory/Properties/InMemoryStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,10 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="DefaultIfEmptyAppliedAfterProjection" xml:space="preserve">
<value>Cannot apply DefaultIfEmpty after a client-evaluated projection.</value>
<value>Cannot apply 'DefaultIfEmpty' after a client-evaluated projection. Consider applying 'DefaultIfEmpty' before last 'Select' or use 'AsEnumerable' before 'DefaultIfEmpty' to apply it on client-side.</value>
</data>
<data name="InvalidDerivedTypeInEntityProjection" xml:space="preserve">
<value>'UpdateEntityType' called with '{derivedType}' which is not derived type of '{entityType}'.</value>
</data>
<data name="InvalidStateEncountered" xml:space="preserve">
<value>Invalid {state} encountered.</value>
<value>The specified entity type '{derivedType}' is not derived from '{entityType}'.</value>
</data>
<data name="LogSavedChanges" xml:space="preserve">
<value>Saved {count} entities to in-memory store.</value>
Expand Down
Loading

0 comments on commit e96b1a2

Please sign in to comment.