private addTransformFn()

in glean/src/core/metrics/types/string_list.ts [128:151]


  private addTransformFn(value: string) {
    return (v?: JSONValue): StringListMetric => {
      const metric = new StringListMetric([value]);
      try {
        v && metric.concat(v);
      } catch (e) {
        if (e instanceof MetricValidationError && e.type !== ErrorType.InvalidType) {
          // We only want to bubble up errors that are not invalid type,
          // those are only useful if it was the user that passed on an incorrect value
          // and in this context that would mean there is invalid data in the database.
          throw e;
        } else {
          log(
            LOG_TAG,
            `Unexpected value found in storage for metric ${this.name}: ${JSON.stringify(
              v
            )}. Overwriting.`
          );
        }
      }

      return metric;
    };
  }