Package winterwell.utils

Examples of winterwell.utils.FailureException


      for (; index.value < json.length(); index.value++) {
        Object k = fromJson2(json, index);
        Object marker = fromJson2(json, index);
        Object v = fromJson2(json, index);
        if (marker != ":")
          throw new FailureException(json);
        array.put(k, v);
      }
      return array;
    }
    if (ci == '}')
View Full Code Here


            dd = home + "/" + dd.substring(1);
          }
        }
        File f = new File(dd).getCanonicalFile();
        if (!f.exists())
          throw new FailureException(
              "Path does not exist: WINTERWELL_HOME = " + f);
        return f;
      }

      // (home)/winterwell?
      String home = System.getProperty("user.home");
      // No home? try /home/winterwell?
      if (Utils.isBlank(home)) {
        home = "/home";
      }
      File ddf = new File(home, "winterwell").getCanonicalFile();
      if (ddf.exists() && ddf.isDirectory())
        return ddf;

      // Give up
      throw new FailureException(
          "Could not find directory - environment variable WINTERWELL_HOME is not set.");
    } catch (IOException e) {
      throw Utils.runtime(e);
    }
  }
View Full Code Here

    // look for an IPv4 address?
    if (returnIP) {
      Matcher m = IP4_ADDRESS.matcher(out);
      if (m.find())
        return m.group();
      throw new FailureException("Couldn't find IP address for " + site
          + " in " + out);
    }

    // look for a name
    String[] bits = StrUtils.splitLines(out);
    String ip = null;
    for (String string : bits) {
      if (string.isEmpty()) {
        continue;
      }
      if (IP4_ADDRESS.matcher(string).matches()) {
        ip = string;
        continue;
      }
      if (string.endsWith(".")) {
        string = string.substring(0, string.length() - 1);
      }
      return string;
    }

    // try a reverse lookup
    if (ip == null)
      throw new FailureException("Couldn't find server name or ip for "
          + site + " in [" + out + "] " + p.getError());
    return dig(ip, false);
  }
View Full Code Here

      final File md = File.createTempFile("tmp", ".md");
      FileUtils.write(md, text);
      Process process = new Process(cmd+" "+md.getAbsolutePath());
      process.run();
      int ok = process.waitFor(10000);
      if (ok != 0) throw new FailureException(cmd+" failed:\n"+process.getError());
      String html = process.getOutput();
      FileUtils.delete(md);
      return html;
    } catch (Exception e) {
      throw Utils.runtime(e);
View Full Code Here

TOP

Related Classes of winterwell.utils.FailureException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.