public static void EnrichWithErrorCode(ExecutionError error, Exception rootCause) { var code = rootCause.GetType().Name; if (code != "Exception") { code = code.Replace("Exception", string.Empty); } error.Extend("code", code.ToUpperInvariant()); }
public static ExecutionError DefaultFormatError(ExecutionOptions options, Exception exception) { var rootCause = exception.GetBaseException(); var message = rootCause.Message; var error = new ExecutionError() { Message = message }; EnrichWithErrorCode(error, rootCause); if (options.IncludeExceptionDetails) { EnrichWithStackTrace(error, rootCause); } if (!(exception is QueryExecutionException graphQLError)) { return(error); } error.Locations = graphQLError.Nodes? .Where(n => n.Location != null) .Select(n => n.Location.Value) .ToList(); error.Path = graphQLError.Path?.Segments.ToList(); if (graphQLError.Extensions != null) { foreach (var extension in graphQLError.Extensions) { error.Extend(extension.Key, extension.Value); } } return(error); }
public static void EnrichWithStackTrace(ExecutionError error, Exception exception) { error.Extend("stacktrace", exception.ToString()); }