Browse Source

Error handling improved.

pull/222/head
Sebastian Stehle 8 years ago
parent
commit
9a7e01f7c4
  1. 26
      src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppMutationsGraphType.cs
  2. 1
      src/Squidex/Squidex.csproj
  3. 1
      src/Squidex/WebStartup.cs

26
src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/AppMutationsGraphType.cs

@ -8,6 +8,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using GraphQL;
using GraphQL.Resolvers;
using GraphQL.Types;
using Newtonsoft.Json.Linq;
@ -307,16 +308,31 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
private static IFieldResolver ResolveAsync<T>(Func<ResolveFieldContext, Func<SquidexCommand, Task<CommandContext>>, Task<T>> action)
{
return new FuncFieldResolver<Task<T>>(c =>
return new FuncFieldResolver<Task<T>>(async c =>
{
var e = (GraphQLExecutionContext)c.UserContext;
return action(c, command =>
try
{
command.ExpectedVersion = c.GetArgument("expectedVersion", EtagVersion.Any);
return await action(c, command =>
{
command.ExpectedVersion = c.GetArgument("expectedVersion", EtagVersion.Any);
return e.CommandBus.PublishAsync(command);
});
}
catch (ValidationException ex)
{
c.Errors.Add(new ExecutionError(ex.Message));
return e.CommandBus.PublishAsync(command);
});
throw;
}
catch (DomainException ex)
{
c.Errors.Add(new ExecutionError(ex.Message));
throw;
}
});
}

1
src/Squidex/Squidex.csproj

@ -48,6 +48,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Ben.BlockingDetector" Version="0.0.1" />
<PackageReference Include="EventStore.ClientAPI.NetCore" Version="4.0.2-rc" />
<PackageReference Include="IdentityServer4" Version="2.0.6" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.2.0" />

1
src/Squidex/WebStartup.cs

@ -6,6 +6,7 @@
// ==========================================================================
using System;
using Ben.Diagnostics;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;

Loading…
Cancel
Save