public GeneratorException(HotChocolate.IError error) : base(error?.Message) { Errors = error == null ? Array.Empty <HotChocolate.IError>() : new[] { error }; }
private async Task <IReadOnlyList <DocumentInfo> > GetGraphQLFiles( string path, ICollection <HCError> errors) { var documents = new List <DocumentInfo>(); foreach (string file in Directory.GetFiles(path, "*.graphql")) { byte[] buffer = await File.ReadAllBytesAsync(file); try { DocumentNode document = Utf8GraphQLParser.Parse(buffer); if (document.Definitions.Count > 0) { DocumentKind kind = document.Definitions.Any(t => t is ITypeSystemDefinitionNode) ? DocumentKind.Schema : DocumentKind.Query; documents.Add(new DocumentInfo { Kind = kind, FileName = file, Document = document }); } } catch (SyntaxException ex) { HCError error = HCErrorBuilder.New() .SetMessage(ex.Message) .AddLocation(ex.Line, ex.Column) .SetCode("SYNTAX_ERROR") .SetExtension("fileName", file) .Build(); errors.Add(error); return(Array.Empty <DocumentInfo>()); } } return(documents); }
public static void Write(this HCError error, StringBuilder message) { message.Clear(); if (error.Extensions is { } && error.Extensions.ContainsKey("fileName"))
public static void Write(this HCError error) { Write(error, new StringBuilder()); }
public void WriteError(HotChocolate.IError error) { _hasErrors = true; error.Write(); _errorReceived(); }
public void WriteError(HotChocolate.IError error) { _hasErrors = true; _data.Errors.Add(new JsonConsoleOutputErrorData(error)); }
public JsonConsoleOutputErrorData(HotChocolate.IError error) { Message = error.Message; Code = error.Code; if (error.Extensions is { } && error.Extensions.ContainsKey("fileName"))