/** * Prints an error message and the usage string, and then exits. * * @param errorMsg The error message to print. */ static final RuntimeException exitWithError(String errorMsg) { throw new CommandLineError("Error: " + errorMsg); }
/** * Prints an error message and the usage string, and then exits. * * @param errorMsg The error message to print. */ static final RuntimeException exitWithError(String errorMsg) { throw new CommandLineError("Error: " + errorMsg); }
/** * Private helper for creating objects from flags. * * @param instanceClassName The name of the class to instantiate. * @return A new instance of the specified plugin module. */ private static <T> T instantiateObject( String flagName, String objectType, Class<T> clazz, ClassLoader loader, String instanceClassName) { try { return Class.forName(instanceClassName, true, loader) .asSubclass(clazz) .getConstructor() .newInstance(); } catch (ReflectiveOperationException e) { throw new CommandLineError( String.format( "Cannot instantiate %s \"%s\" registered with flag --%s. Please make " + "sure that the %s exists and is on the compiler classpath and has a public " + "zero arguments constructor.\nCaused by: %s", objectType, instanceClassName, flagName, objectType, e)); } } }
private ValidatedLoggingConfig parseLoggingConfig() { if (loggingConfig != null) { try (InputStream stream = new FileInputStream(loggingConfig)) { return ValidatedLoggingConfig.create(LoggingConfig.parseFrom(stream)); } catch (IllegalArgumentException e) { throw new CommandLineError( "Error parsing logging config proto: " + loggingConfig + ": " + e.getMessage()); } catch (InvalidProtocolBufferException e) { throw new CommandLineError( "Invalid conformance proto: " + loggingConfig + ": " + e.getMessage()); } catch (IOException e) { throw new CommandLineError( "Unable to read conformance proto: " + loggingConfig + ": " + e.getMessage()); } } else { return ValidatedLoggingConfig.EMPTY; } }
/** * Private helper for createInjector(). * * @param moduleName The name of the plugin module to instantiate. * @return A new instance of the specified plugin module. */ private static <T> T instantiateObject( String moduleFlagName, String objectType, Class<T> clazz, ClassLoader loader, String moduleName) { try { return Class.forName(moduleName, true, loader) .asSubclass(clazz) .getConstructor() .newInstance(); } catch (ReflectiveOperationException e) { throw new CommandLineError( String.format( "Cannot instantiate %s \"%s\" registered with flag --%s. Please make " + "sure that the %s exists and is on the compiler classpath.\nCaused by: %s", objectType, moduleName, moduleFlagName, objectType, e)); } } }
private ValidatedLoggingConfig parseLoggingConfig() { if (loggingConfig != null) { try (InputStream stream = new FileInputStream(loggingConfig)) { return ValidatedLoggingConfig.create(LoggingConfig.parseFrom(stream)); } catch (IllegalArgumentException e) { throw new CommandLineError( "Error parsing logging config proto: " + loggingConfig + ": " + e.getMessage()); } catch (InvalidProtocolBufferException e) { throw new CommandLineError( "Invalid conformance proto: " + loggingConfig + ": " + e.getMessage()); } catch (IOException e) { throw new CommandLineError( "Unable to read conformance proto: " + loggingConfig + ": " + e.getMessage()); } } else { return ValidatedLoggingConfig.EMPTY; } }
private ValidatedConformanceConfig parseConformanceConfig() { if (conformanceConfig != null) { try (InputStream stream = new FileInputStream(conformanceConfig)) { return ValidatedConformanceConfig.create(ConformanceConfig.parseFrom(stream)); } catch (IllegalArgumentException e) { throw new CommandLineError( "Error parsing conformance proto: " + conformanceConfig + ": " + e.getMessage()); } catch (InvalidProtocolBufferException e) { throw new CommandLineError( "Invalid conformance proto: " + conformanceConfig + ": " + e.getMessage()); } catch (IOException e) { throw new CommandLineError( "Unable to read conformance proto: " + conformanceConfig + ": " + e.getMessage()); } } else { return ValidatedConformanceConfig.EMPTY; } }
private ValidatedConformanceConfig parseConformanceConfig() { if (conformanceConfig != null) { try (InputStream stream = new FileInputStream(conformanceConfig)) { return ValidatedConformanceConfig.create(ConformanceConfig.parseFrom(stream)); } catch (IllegalArgumentException e) { throw new CommandLineError( "Error parsing conformance proto: " + conformanceConfig + ": " + e.getMessage()); } catch (InvalidProtocolBufferException e) { throw new CommandLineError( "Invalid conformance proto: " + conformanceConfig + ": " + e.getMessage()); } catch (IOException e) { throw new CommandLineError( "Unable to read conformance proto: " + conformanceConfig + ": " + e.getMessage()); } } else { return ValidatedConformanceConfig.EMPTY; } }
sfsBuilder.addProtoDescriptorsFromFile(protoFileDescriptor); } catch (IOException ioe) { throw new CommandLineError( "Error parsing proto file descriptor from " + protoFileDescriptor
sfsBuilder.addProtoDescriptorsFromFile(protoFileDescriptor); } catch (IOException ioe) { throw new CommandLineError( "Error parsing proto file descriptor from " + protoFileDescriptor