private static TResult GetPropertyEx()

in JetBrains.Etw.HostService.Updater/src/Util/JsonUtil.cs [10:28]


    private static TResult GetPropertyEx<TResult>(this JsonElement element, [NotNull] string propertyName, [NotNull] Func<JsonElement, TResult> func)
    {
      if (func == null)
        throw new ArgumentNullException(nameof(func));
      if (!element.TryGetProperty(propertyName, out var childElement))
        throw new KeyNotFoundException($"Failed to find string property {propertyName}");
      try
      {
        return func(childElement);
      }
      catch (FormatException e)
      {
        throw new FormatException($"Failed to parse property {propertyName}", e);
      }
      catch (InvalidOperationException e)
      {
        throw new InvalidOperationException($"Failed to get property {propertyName}", e);
      }
    }