public static IQueryError CreateError( this ResolverTask resolverTask, Exception exception) { if (resolverTask.Options.DeveloperMode) { return(resolverTask.CreateError( $"{exception.Message}\r\n\r\n{exception.StackTrace}")); } else { return(resolverTask.CreateError("Unexpected execution error.")); } }
private static async Task <object> ExecuteMiddlewareAsync( ResolverTask resolverTask, CancellationToken cancellationToken) { object result = null; try { if (!resolverTask.FieldSelection.Field.IsIntrospectionField && resolverTask.HasMiddleware) { result = await ExecuteDirectiveMiddlewareAsync( resolverTask, cancellationToken); } else { result = await ExecuteFieldMiddlewareAsync( resolverTask, cancellationToken); } } catch (QueryException ex) { result = ex.Errors; } catch (Exception ex) { ResolverDiagnosticEvents.ResolverError( resolverTask.ResolverContext, ex); result = resolverTask.CreateError(ex); } return(result); }