Returns the given environment variable, throwing a descriptive error if it doesn't exist.
(String key, String whatItIs)
| 19 | public class EnvMisc { |
| 20 | /** Returns the given environment variable, throwing a descriptive error if it doesn't exist. */ |
| 21 | public static String get(String key, String whatItIs) { |
| 22 | String value = System.getenv(key); |
| 23 | if (value != null) { |
| 24 | return value; |
| 25 | } else { |
| 26 | throw new IllegalArgumentException("You must set environment variable '" + key + "' to " + whatItIs); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | /** Returns the given environment variable, printing a descriptive warning and using a default value if it doesn't exist. */ |
| 31 | public static String getOptional(String key, String defaultValue, String whatItIs) { |
no outgoing calls