public static int parseUInt(String s, String errorMsg) throws Exception {
        try {
            int x = Integer.parseInt(s.trim());
            if (x < 0) throw new Exception();
            return x;
        } catch (Exception e) {
            throw new Exception(errorMsg);
        }
    }