From 68ba1149c0afc9b916a3eaa9337b5e8e1a0fc9df Mon Sep 17 00:00:00 2001 From: Jorrit Schippers Date: Tue, 24 Jan 2023 15:00:10 +0100 Subject: [PATCH] Add message to exception when enum conversion fails --- .../Generators/EnumParserGenerator.cs | 8 +++++--- .../Integration/MultiProfileTest.Client.cs | 4 ++-- .../StarWarsIntrospectionTest.Client.cs | 4 ++-- ...berryShake.CodeGeneration.CSharp.Tests.csproj | 2 +- ...ests.Generate_StarWars_Client_With_Defer.snap | 4 ++-- ...OrIdGeneratorTests.UnionWithNestedObject.snap | 4 ++-- .../ErrorGeneratorTests.Generate_NoErrors.snap | 4 ++-- ...eratorTests.Interface_With_Default_Names.snap | 4 ++-- ...eratorTests.Operation_With_Leaf_Argument.snap | 4 ++-- ...eratorTests.Operation_With_Type_Argument.snap | 4 ++-- ...rTests.Generate_ChatClient_AllOperations.snap | 4 ++-- ...s.Complete_Schema_With_Uuid_And_DateTime.snap | 8 ++++---- ...ratorTests.Create_UpdateMembers_Mutation.snap | 4 ++-- ...GeneratorTests.FieldsWithUnderlineInName.snap | 12 ++++++------ .../SchemaGeneratorTests.HasuraMutation.snap | 16 ++++++++-------- .../SchemaGeneratorTests.IntrospectionQuery.snap | 4 ++-- .../SchemaGeneratorTests.NonNullLists.snap | 4 ++-- .../SchemaGeneratorTests.QueryInterference.snap | 4 ++-- ...eratorTests.Interface_With_Default_Names.snap | 4 ++-- ...eratorTests.Operation_With_Leaf_Argument.snap | 4 ++-- ...eratorTests.Operation_With_Type_Argument.snap | 4 ++-- 21 files changed, 56 insertions(+), 54 deletions(-) diff --git a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/EnumParserGenerator.cs b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/EnumParserGenerator.cs index cfceb171fb2..be588a1d82e 100644 --- a/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/EnumParserGenerator.cs +++ b/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/Generators/EnumParserGenerator.cs @@ -57,7 +57,8 @@ private ICode CreateEnumParsingSwitch( .New() .SetReturn() .SetExpression(serializedValue) - .SetDefaultCase(ExceptionBuilder.Inline(TypeNames.GraphQLClientException)); + .SetDefaultCase(ExceptionBuilder.Inline(TypeNames.GraphQLClientException) + .AddArgument($"$\"String value '{{serializedValue}}' can't be converted to enum {descriptor.Name}\"")); foreach (var enumValue in descriptor.Values) { @@ -77,7 +78,8 @@ private ICode CreateEnumFormattingSwitch( SwitchExpressionBuilder.New() .SetReturn() .SetExpression(runtimeValue) - .SetDefaultCase(ExceptionBuilder.Inline(TypeNames.GraphQLClientException)); + .SetDefaultCase(ExceptionBuilder.Inline(TypeNames.GraphQLClientException) + .AddArgument($"$\"Enum {descriptor.Name} value '{{runtimeValue}}' can't be converted to string\"")); foreach (var enumValue in descriptor.Values) { @@ -88,4 +90,4 @@ private ICode CreateEnumFormattingSwitch( return switchExpression; } -} \ No newline at end of file +} diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs index 2090b5ac534..1738cf0d231 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/MultiProfileTest.Client.cs @@ -1164,7 +1164,7 @@ public Episode Parse(global::System.String serializedValue) "NEW_HOPE" => Episode.NewHope, "EMPIRE" => Episode.Empire, "JEDI" => Episode.Jedi, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Episode")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -1174,7 +1174,7 @@ public Episode Parse(global::System.String serializedValue) Episode.NewHope => "NEW_HOPE", Episode.Empire => "EMPIRE", Episode.Jedi => "JEDI", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Episode value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.Client.cs b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.Client.cs index 3df4cbeef5b..8b650dc48ae 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.Client.cs +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/Integration/StarWarsIntrospectionTest.Client.cs @@ -2854,7 +2854,7 @@ public __TypeKind Parse(global::System.String serializedValue) "INPUT_OBJECT" => __TypeKind.InputObject, "LIST" => __TypeKind.List, "NON_NULL" => __TypeKind.NonNull, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum __TypeKind")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -2869,7 +2869,7 @@ public __TypeKind Parse(global::System.String serializedValue) __TypeKind.InputObject => "INPUT_OBJECT", __TypeKind.List => "LIST", __TypeKind.NonNull => "NON_NULL", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum __TypeKind value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/StrawberryShake.CodeGeneration.CSharp.Tests.csproj b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/StrawberryShake.CodeGeneration.CSharp.Tests.csproj index 7aa7ee8afbd..fc46198ca6e 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/StrawberryShake.CodeGeneration.CSharp.Tests.csproj +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/StrawberryShake.CodeGeneration.CSharp.Tests.csproj @@ -1,4 +1,4 @@ - + false diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_StarWars_Client_With_Defer.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_StarWars_Client_With_Defer.snap index 92b503cba8e..745ee9cb0be 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_StarWars_Client_With_Defer.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityGeneratorTests.Generate_StarWars_Client_With_Defer.snap @@ -741,7 +741,7 @@ namespace Foo.Bar "NEW_HOPE" => Episode.NewHope, "EMPIRE" => Episode.Empire, "JEDI" => Episode.Jedi, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Episode")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -751,7 +751,7 @@ namespace Foo.Bar Episode.NewHope => "NEW_HOPE", Episode.Empire => "EMPIRE", Episode.Jedi => "JEDI", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Episode value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionWithNestedObject.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionWithNestedObject.snap index 12112733f67..bcb6183bed5 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionWithNestedObject.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/EntityOrIdGeneratorTests.UnionWithNestedObject.snap @@ -500,7 +500,7 @@ namespace Foo.Bar "MISSING_ARGUMENT" => ErrorCode.MissingArgument, "INVALID_ARGUMENT" => ErrorCode.InvalidArgument, "FAILED" => ErrorCode.Failed, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum ErrorCode")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -511,7 +511,7 @@ namespace Foo.Bar ErrorCode.MissingArgument => "MISSING_ARGUMENT", ErrorCode.InvalidArgument => "INVALID_ARGUMENT", ErrorCode.Failed => "FAILED", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum ErrorCode value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap index 93d774d55b5..b467ea75688 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ErrorGeneratorTests.Generate_NoErrors.snap @@ -283,7 +283,7 @@ namespace Foo.Bar "NEW_HOPE" => Episode.NewHope, "EMPIRE" => Episode.Empire, "JEDI" => Episode.Jedi, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Episode")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -293,7 +293,7 @@ namespace Foo.Bar Episode.NewHope => "NEW_HOPE", Episode.Empire => "EMPIRE", Episode.Jedi => "JEDI", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Episode value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Default_Names.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Default_Names.snap index 0034ed2ff28..d78a8b6b529 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Default_Names.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Interface_With_Default_Names.snap @@ -283,7 +283,7 @@ namespace Foo.Bar "NEW_HOPE" => Episode.NewHope, "EMPIRE" => Episode.Empire, "JEDI" => Episode.Jedi, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Episode")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -293,7 +293,7 @@ namespace Foo.Bar Episode.NewHope => "NEW_HOPE", Episode.Empire => "EMPIRE", Episode.Jedi => "JEDI", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Episode value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Leaf_Argument.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Leaf_Argument.snap index 04ef2d7d5d8..e9ebacc034b 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Leaf_Argument.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Leaf_Argument.snap @@ -283,7 +283,7 @@ namespace Foo.Bar "NEW_HOPE" => Episode.NewHope, "EMPIRE" => Episode.Empire, "JEDI" => Episode.Jedi, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Episode")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -293,7 +293,7 @@ namespace Foo.Bar Episode.NewHope => "NEW_HOPE", Episode.Empire => "EMPIRE", Episode.Jedi => "JEDI", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Episode value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Type_Argument.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Type_Argument.snap index ce81f1c7ac8..c9d6568901c 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Type_Argument.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/NoStoreStarWarsGeneratorTests.Operation_With_Type_Argument.snap @@ -337,7 +337,7 @@ namespace Foo.Bar "NEW_HOPE" => Episode.NewHope, "EMPIRE" => Episode.Empire, "JEDI" => Episode.Jedi, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Episode")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -347,7 +347,7 @@ namespace Foo.Bar Episode.NewHope => "NEW_HOPE", Episode.Empire => "EMPIRE", Episode.Jedi => "JEDI", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Episode value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap index 5a51eb1879a..e1d0736cb0c 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/OperationGeneratorTests.Generate_ChatClient_AllOperations.snap @@ -2588,7 +2588,7 @@ namespace Foo.Bar { "INCOMING" => Direction.Incoming, "OUTGOING" => Direction.Outgoing, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Direction")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -2597,7 +2597,7 @@ namespace Foo.Bar { Direction.Incoming => "INCOMING", Direction.Outgoing => "OUTGOING", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Direction value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_Uuid_And_DateTime.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_Uuid_And_DateTime.snap index f13bd6c9220..2caf2bff677 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_Uuid_And_DateTime.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/ScalarGeneratorTests.Complete_Schema_With_Uuid_And_DateTime.snap @@ -346,7 +346,7 @@ namespace Foo.Bar "EDUCATION" => ExpenseCategory.Education, "MISCELLANEOUS" => ExpenseCategory.Miscellaneous, "PERSONAL_CARE" => ExpenseCategory.PersonalCare, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum ExpenseCategory")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -369,7 +369,7 @@ namespace Foo.Bar ExpenseCategory.Education => "EDUCATION", ExpenseCategory.Miscellaneous => "MISCELLANEOUS", ExpenseCategory.PersonalCare => "PERSONAL_CARE", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum ExpenseCategory value '{runtimeValue}' can't be converted to string")}; } } @@ -398,7 +398,7 @@ namespace Foo.Bar "DEBIT_CARD" => PaymentMethod.DebitCard, "CREDIT_CARD" => PaymentMethod.CreditCard, "PAY_PAL" => PaymentMethod.PayPal, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum PaymentMethod")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -410,7 +410,7 @@ namespace Foo.Bar PaymentMethod.DebitCard => "DEBIT_CARD", PaymentMethod.CreditCard => "CREDIT_CARD", PaymentMethod.PayPal => "PAY_PAL", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum PaymentMethod value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_UpdateMembers_Mutation.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_UpdateMembers_Mutation.snap index 8f21cc05879..a704e5f12d2 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_UpdateMembers_Mutation.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.Create_UpdateMembers_Mutation.snap @@ -593,7 +593,7 @@ namespace Foo.Bar "VIEWER" => ProjectUserRoleType.Viewer, "EDITOR" => ProjectUserRoleType.Editor, "OWNER" => ProjectUserRoleType.Owner, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum ProjectUserRoleType")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -603,7 +603,7 @@ namespace Foo.Bar ProjectUserRoleType.Viewer => "VIEWER", ProjectUserRoleType.Editor => "EDITOR", ProjectUserRoleType.Owner => "OWNER", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum ProjectUserRoleType value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap index fdf832c4aa1..98569ec32f8 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.FieldsWithUnderlineInName.snap @@ -2855,7 +2855,7 @@ namespace Foo.Bar "MONTH" => TimeUnit.Month, "QUARTER" => TimeUnit.Quarter, "YEAR" => TimeUnit.Year, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum TimeUnit")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -2871,7 +2871,7 @@ namespace Foo.Bar TimeUnit.Month => "MONTH", TimeUnit.Quarter => "QUARTER", TimeUnit.Year => "YEAR", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum TimeUnit value '{runtimeValue}' can't be converted to string")}; } } @@ -2898,7 +2898,7 @@ namespace Foo.Bar "SUM" => Aggregation.Sum, "MIN" => Aggregation.Min, "MAX" => Aggregation.Max, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Aggregation")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -2909,7 +2909,7 @@ namespace Foo.Bar Aggregation.Sum => "SUM", Aggregation.Min => "MIN", Aggregation.Max => "MAX", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Aggregation value '{runtimeValue}' can't be converted to string")}; } } @@ -2934,7 +2934,7 @@ namespace Foo.Bar "NO_VALUE" => DataFlag.NoValue, "VALID" => DataFlag.Valid, "MISSING" => DataFlag.Missing, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum DataFlag")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -2944,7 +2944,7 @@ namespace Foo.Bar DataFlag.NoValue => "NO_VALUE", DataFlag.Valid => "VALID", DataFlag.Missing => "MISSING", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum DataFlag value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.HasuraMutation.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.HasuraMutation.snap index e86a5600303..0920f51a084 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.HasuraMutation.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.HasuraMutation.snap @@ -3333,7 +3333,7 @@ namespace Foo.Bar return serializedValue switch { "people_pkey" => People_constraint.PeoplePkey, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum People_constraint")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -3341,7 +3341,7 @@ namespace Foo.Bar return runtimeValue switch { People_constraint.PeoplePkey => "people_pkey", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum People_constraint value '{runtimeValue}' can't be converted to string")}; } } @@ -3378,7 +3378,7 @@ namespace Foo.Bar "firstName" => People_update_column.Firstname, "id" => People_update_column.Id, "lastName" => People_update_column.Lastname, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum People_update_column")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -3388,7 +3388,7 @@ namespace Foo.Bar People_update_column.Firstname => "firstName", People_update_column.Id => "id", People_update_column.Lastname => "lastName", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum People_update_column value '{runtimeValue}' can't be converted to string")}; } } @@ -3415,7 +3415,7 @@ namespace Foo.Bar return serializedValue switch { "cars_pkey" => Cars_constraint.CarsPkey, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Cars_constraint")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -3423,7 +3423,7 @@ namespace Foo.Bar return runtimeValue switch { Cars_constraint.CarsPkey => "cars_pkey", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Cars_constraint value '{runtimeValue}' can't be converted to string")}; } } @@ -3460,7 +3460,7 @@ namespace Foo.Bar "carName" => Cars_update_column.Carname, "id" => Cars_update_column.Id, "ownerId" => Cars_update_column.Ownerid, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Cars_update_column")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -3470,7 +3470,7 @@ namespace Foo.Bar Cars_update_column.Carname => "carName", Cars_update_column.Id => "id", Cars_update_column.Ownerid => "ownerId", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Cars_update_column value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.IntrospectionQuery.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.IntrospectionQuery.snap index 7a90b9ae478..3e78604e437 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.IntrospectionQuery.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.IntrospectionQuery.snap @@ -2768,7 +2768,7 @@ namespace Foo.Bar "INPUT_OBJECT" => __TypeKind.InputObject, "LIST" => __TypeKind.List, "NON_NULL" => __TypeKind.NonNull, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum __TypeKind")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -2783,7 +2783,7 @@ namespace Foo.Bar __TypeKind.InputObject => "INPUT_OBJECT", __TypeKind.List => "LIST", __TypeKind.NonNull => "NON_NULL", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum __TypeKind value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NonNullLists.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NonNullLists.snap index 1d8624527ae..3ae379b93d4 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NonNullLists.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.NonNullLists.snap @@ -280,7 +280,7 @@ namespace Foo.Bar { "ITEM1" => Amenity.Item1, "ITEM2" => Amenity.Item2, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Amenity")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -289,7 +289,7 @@ namespace Foo.Bar { Amenity.Item1 => "ITEM1", Amenity.Item2 => "ITEM2", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Amenity value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap index eb0ea433b7a..1ab308d5ab6 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/SchemaGeneratorTests.QueryInterference.snap @@ -2198,7 +2198,7 @@ namespace Foo.Bar { "ASC" => SortEnumType.Asc, "DESC" => SortEnumType.Desc, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum SortEnumType")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -2207,7 +2207,7 @@ namespace Foo.Bar { SortEnumType.Asc => "ASC", SortEnumType.Desc => "DESC", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum SortEnumType value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap index 93d774d55b5..b467ea75688 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Interface_With_Default_Names.snap @@ -283,7 +283,7 @@ namespace Foo.Bar "NEW_HOPE" => Episode.NewHope, "EMPIRE" => Episode.Empire, "JEDI" => Episode.Jedi, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Episode")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -293,7 +293,7 @@ namespace Foo.Bar Episode.NewHope => "NEW_HOPE", Episode.Empire => "EMPIRE", Episode.Jedi => "JEDI", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Episode value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap index 9c844f15a8f..c4d95733363 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Leaf_Argument.snap @@ -283,7 +283,7 @@ namespace Foo.Bar "NEW_HOPE" => Episode.NewHope, "EMPIRE" => Episode.Empire, "JEDI" => Episode.Jedi, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Episode")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -293,7 +293,7 @@ namespace Foo.Bar Episode.NewHope => "NEW_HOPE", Episode.Empire => "EMPIRE", Episode.Jedi => "JEDI", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Episode value '{runtimeValue}' can't be converted to string")}; } } diff --git a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Type_Argument.snap b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Type_Argument.snap index 80cd7ff1af7..931498c13d8 100644 --- a/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Type_Argument.snap +++ b/src/StrawberryShake/CodeGeneration/test/CodeGeneration.CSharp.Tests/__snapshots__/StarWarsGeneratorTests.Operation_With_Type_Argument.snap @@ -337,7 +337,7 @@ namespace Foo.Bar "NEW_HOPE" => Episode.NewHope, "EMPIRE" => Episode.Empire, "JEDI" => Episode.Jedi, - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"String value '{serializedValue}' can't be converted to enum Episode")}; } public global::System.Object Format(global::System.Object? runtimeValue) @@ -347,7 +347,7 @@ namespace Foo.Bar Episode.NewHope => "NEW_HOPE", Episode.Empire => "EMPIRE", Episode.Jedi => "JEDI", - _ => throw new global::StrawberryShake.GraphQLClientException()}; + _ => throw new global::StrawberryShake.GraphQLClientException($"Enum Episode value '{runtimeValue}' can't be converted to string")}; } }