Пример #1
0
 public static ConfigLookupError parseErrorFor <A>(
     ConfigPath path, object node, string extraInfo = null
     ) =>
 ConfigLookupError.wrongType(F.lazy(() => ImmutableArray.Create(
                                        F.t("path", path.pathStrWithBase),
                                        F.t("type", typeof(A).FullName),
                                        F.t("extraInfo", extraInfo ?? ""),
                                        F.t("node-contents", node.asDebugString())
                                        )));
Пример #2
0
        public static ConfigLookupError parseErrorFor <A>(
            ConfigPath path, object node, string extraInfo = null
            )
        {
            var extraS = extraInfo == null ? "" : $", {extraInfo}";

            return(ConfigLookupError.wrongType(F.lazy(() =>
                                                      $"Can't parse {path} as {typeof(A)}{extraS}, node contents: {node.asDebugString()}"
                                                      )));
        }
Пример #3
0
        Either <ConfigLookupError, A> fetch <A>(
            IDictionary <string, object> current, ConfigPath path, string part, Parser <A> parser
            )
        {
            if (!current.ContainsKey(part))
            {
                return(F.left <ConfigLookupError, A>(ConfigLookupError.keyNotFound(F.lazy(() =>
                                                                                          $"Cannot find part '{part}' from path '{path}' in {current.asDebugString()} " +
                                                                                          $"[{nameof(scope)}='{scope}']"
                                                                                          ))));
            }

            var node = current[part];

            return(parser(path, node));
        }
Пример #4
0
        Either <ConfigLookupError, A> fetch <A>(
            IDictionary <string, object> current, ConfigPath path, string part, Parser <A> parser
            )
        {
            if (!current.ContainsKey(part))
            {
                return(F.left <ConfigLookupError, A>(ConfigLookupError.keyNotFound(F.lazy(() => ImmutableArray.Create(
                                                                                              F.t(nameof(part), part),
                                                                                              F.t(nameof(path), path.pathStrWithBase),
                                                                                              F.t(nameof(current), current.asDebugString()),
                                                                                              F.t(nameof(scope), scope.pathStrWithBase)
                                                                                              )))));
            }

            var node = current[part];

            return(parser(path, node));
        }
Пример #5
0
 public ConfigFetchException(ConfigLookupError error) : base(error.ToString())
 {
     this.error = error;
 }