List of usage examples for java.lang Error Error
public Error(Throwable cause)
From source file:org.usrz.libs.webtools.validation.ValidationInterceptor.java
@Override public Object aroundReadFrom(ReaderInterceptorContext context) throws IOException, WebApplicationException { final Object object = context.proceed(); if (object == null) return null; log.debug("Validating class %s", object.getClass().getName()); final Set<ConstraintViolation<Object>> violations = validator.validate(object); if ((violations == null) || (violations.isEmpty())) return object; final List<Error> errors = new ArrayList<>(); violations.forEach((violation) -> errors.add(new Error(violation))); throw new WebApplicationExceptionBuilder(BAD_REQUEST).message("Violation constraint in API") .with(withName, errors).build(); }
From source file:org.ambraproject.journal.JournalCreatorImpl.java
/** * Journal create the journal/* ww w .j a v a 2 s . co m*/ * * @param template the hibernate template to use * @param key the journal key * @throws org.topazproject.otm.OtmException on an error * @throws Error on a fatal error */ private void createJournal(HibernateTemplate template, final String key) { template.execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { log.info("Attempting create/update journal with key '" + key + "'"); String cKey = "ambra.virtualJournals." + key + ".eIssn"; String eIssn = configuration.getString(cKey); if (eIssn == null) throw new Error("Missing config entry '" + cKey + "'"); String title = configuration.getString("ambra.virtualJournals." + key + ".description"); @SuppressWarnings("unchecked") List<Journal> journals = session.createCriteria(Journal.class).add(Restrictions.eq("key", key)) .list(); Journal journal; if (journals.size() != 0) { journal = journals.get(0); } else { journal = new Journal(); journal.setKey(key); } if (title != null) { journal.setTitle(title); } journal.seteIssn(eIssn); //Generate the journal Id first so the dublin core can have a matching identifier session.saveOrUpdate(journal); if (journals.size() != 0) log.info("Updated journal with key '" + key + "'"); else log.info("Created journal with key '" + key + "'"); return null; } }); }
From source file:DoubleDocument.java
public double getValue() { try {//from w ww .j av a2s.c o m String t = getText(0, getLength()); if (t != null && t.length() > 0) { return Double.parseDouble(t); } else { return 0; } } catch (BadLocationException e) { // Will not happen because we are sure // we use the proper range throw new Error(e.getMessage()); } }
From source file:be.fgov.kszbcss.rhq.websphere.component.jdbc.db2.DB2MonitorComponent.java
protected void doStart() throws InvalidPluginConfigurationException { dataSourceComponent = getParent();// w ww.j a v a 2 s . c om adminOperations = dataSourceComponent.getServer().getMBeanClient("WebSphere:type=AdminOperations,*") .getProxy(AdminOperations.class); Configuration config = getResourceContext().getPluginConfiguration(); principal = config.getSimpleValue("principal", null); credentials = config.getSimpleValue("credentials", null); try { Class.forName("com.ibm.db2.jcc.DB2SimpleDataSource"); } catch (ClassNotFoundException ex) { log.error("DB2 monitor unavailable: JDBC driver not present in the class path"); throw new Error(ex); } if (principal != null) { measurementFacetSupport = new MeasurementFacetSupport(this); measurementFacetSupport.setDefaultHandler(new SnapshotMeasurementGroupHandler(this, adminOperations)); measurementFacetSupport.addHandler("acr", new ACRMeasurementGroupHandler(this)); } }
From source file:net.sourceforge.fenixedu.dataTransferObject.finalDegreeWork.FinalDegreeWorkProposalHeader.java
@Override public void setExternalId(String integer) { throw new Error("Method should not be called!"); }
From source file:com.laxser.blitz.lama.provider.jdbc.PreparedStatementCallbackReturnId.java
private static Object defaultValueOf(Class<?> numberType) { if (numberType == Integer.class) { return new Integer(-1); } else if (numberType == Long.class) { return new Long(-1); }/*from w ww .ja va 2 s . c om*/ throw new Error("wrong number type: " + numberType); }
From source file:com.aestel.chemistry.openEye.fp.Fingerprinter.java
/** * * @param type type of fingerprints to generate. * @param addNewFragments if true new fragments are added to the dictionary use * this to update or create a new dictionary. * @param hashNewFragments hash new fragments into a bit-range exceeding the * bit-range of the dictionary. *//*from www .j av a 2 s .com*/ public static Fingerprinter createFingerprinter(String type, boolean addNewFragments, boolean hashNewFragments) { StructureCodeNameIterator generator; StructureCodeMapper mapper; if ("maccs".equals(type)) { generator = SmartsCodeNameIterator.createFromXML(Constants.MACCSSmartsFile); if (hashNewFragments) throw new Error("hashNewFragments not supported for maccs"); mapper = new TABDictionaryStructureCodeMapper("maccsMap.tab", addNewFragments, false); } else if ("linear7".equals(type)) { generator = new LinearCodeNameGenerator("lin7", 7, 99); mapper = new TABDictionaryStructureCodeMapper("linear7Map.tab", addNewFragments, hashNewFragments); } else if ("linear7*4".equals(type)) { generator = new LinearCodeNameGenerator("lin74", 7, 4); mapper = new TABDictionaryStructureCodeMapper("linear74Map.tab", addNewFragments, hashNewFragments); } else if ("HashLinear7*4".equals(type)) { generator = new LinearCodeNameGenerator("HLin74", 7, 4); if (hashNewFragments) throw new Error("hashNewFragments not supported for HLin74"); if (addNewFragments) throw new Error("addNewFragments not supported for HLin74"); mapper = new HashStructureCodeMapper(0, 16348); } else { throw new Error("Unknown fingerprint type: " + type); } return new Fingerprinter(generator, mapper); }
From source file:com.genentech.struchk.NormalizerPool.java
public GNEMolecule normalizeSmi(String smi, String gneStructFlag) { PooledNormalizer pnorm = null;/*from www .ja v a 2 s. c o m*/ try { pnorm = (PooledNormalizer) pool.borrowObject(); return pnorm.norm.normalizeSmi(smi, gneStructFlag); } catch (Exception e) { handleException(pnorm, e); throw new Error(e); } finally { returnToPool(pnorm); } }
From source file:beast.math.MathUtils.java
/** * @param pdf array of unnormalized probabilities * @return a sample according to an unnormalized probability distribution */// w w w .j a va 2 s . c o m public static int randomChoicePDF(double[] pdf) { double U = MathUtils.nextDouble() * getTotal(pdf); for (int i = 0; i < pdf.length; i++) { U -= pdf[i]; if (U < 0.0) { return i; } } for (int i = 0; i < pdf.length; i++) { System.out.println(i + "\t" + pdf[i]); } throw new Error("randomChoicePDF falls through -- negative, infinite or NaN components in input " + "distribution, or all zeroes?"); }
From source file:edu.unc.lib.dl.services.RepositoryInitializer.java
@Override public void run() { try {/* ww w . j a v a 2s . com*/ if (this.digitalObjectManager == null || this.folderManager == null || this.initialBatchIngestDir == null || this.initialAdministrators == null || this.managementClient == null || this.tripleStoreQueryService == null) { throw new Error("RepositoryInitializer is missing dependencies and cannot run as configured."); } log.warn("Waiting on Fedora startup to initialize repository, polling.."); try { this.managementClient.pollForObject(ContentModelHelper.Fedora_PID.FEDORA_OBJECT.getPID(), 30, 600); } catch (InterruptedException e1) { throw new Error("RepositoryInitializer was interrupted.", e1); } try { this.managementClient.getObjectXML(ContentModelHelper.Administrative_PID.REPOSITORY.getPID()); log.warn("Found an existing repository root, auto-initialization aborted."); return; } catch (Exception e) { log.warn("No existing repository root found, auto-initializing."); } ingestRepositoryManagementSoftwareAgent(); ingestContentModelsServices(); ingestRepositoryFolder(); // we are going to use the DOM now this.getDigitalObjectManager().setAvailable(true, "available"); ingestAdminFolders(); this.digitalObjectManager.setAvailable(true); log.info("Repository was initialized"); } catch (ServiceException e) { log.fatal("Fedora service misconfigured or unavailable during initialization", e); } catch (RuntimeException e) { log.fatal("Could not initialize repository, unexpected exception", e); } catch (Error e) { log.fatal("Could not initialize repository, unexpected exception", e); } }