List of usage examples for java.lang Error Error
public Error(Throwable cause)
From source file:org.r10r.doctester.testbrowser.TestBrowserImpl.java
@Override public Response makeRequest(Request httpRequest) { Response httpResponse;/* w w w . j av a2s. c om*/ if (Sets.newHashSet(HEAD, GET, DELETE).contains(httpRequest.httpRequestType)) { httpResponse = makeHeadGetOrDeleteRequest(httpRequest); } else if (Sets.newHashSet(POST, PUT, PATCH).contains(httpRequest.httpRequestType)) { httpResponse = makePatchPostOrPutRequest(httpRequest); } else { throw new RuntimeErrorException( new Error("Your requested httpRequest.httpRequestType is not supported")); } return httpResponse; }
From source file:com.manydesigns.portofino.actions.admin.tables.forms.ColumnForm.java
public ColumnForm(Column copyFrom, PropertyAccessor columnAccessor, Type type) { try {/*from www .j av a2s. c o m*/ BeanUtils.copyProperties(this, copyFrom); } catch (Exception e) { throw new Error(e); } this.type = type; inPk = DatabaseLogic.isInPk(copyFrom); FieldSize fieldSizeAnn = columnAccessor.getAnnotation(FieldSize.class); if (fieldSizeAnn != null) { fieldSize = fieldSizeAnn.value(); } MaxLength maxLengthAnn = columnAccessor.getAnnotation(MaxLength.class); if (maxLengthAnn != null) { maxLength = maxLengthAnn.value(); } Multiline multilineAnn = columnAccessor.getAnnotation(Multiline.class); if (multilineAnn != null && multilineAnn.value()) { typeOfContent = Multiline.class.getName(); } RichText richTextAnn = columnAccessor.getAnnotation(RichText.class); if (richTextAnn != null && richTextAnn.value()) { typeOfContent = RichText.class.getName(); } if (columnAccessor.isAnnotationPresent(Email.class)) { stringFormat = Email.class.getName(); } if (columnAccessor.isAnnotationPresent(CAP.class)) { stringFormat = CAP.class.getName(); } if (columnAccessor.isAnnotationPresent(CodiceFiscale.class)) { stringFormat = CodiceFiscale.class.getName(); } if (columnAccessor.isAnnotationPresent(PartitaIva.class)) { stringFormat = PartitaIva.class.getName(); } if (columnAccessor.isAnnotationPresent(Password.class)) { stringFormat = Password.class.getName(); } if (columnAccessor.isAnnotationPresent(Phone.class)) { stringFormat = Phone.class.getName(); } HighlightLinks hlAnn = columnAccessor.getAnnotation(HighlightLinks.class); if (hlAnn != null) { highlightLinks = hlAnn.value(); } RegExp regexpAnn = columnAccessor.getAnnotation(RegExp.class); if (regexpAnn != null) { regexp = regexpAnn.value(); } FileBlob fileBlobAnn = columnAccessor.getAnnotation(FileBlob.class); if (fileBlobAnn != null) { fileBlob = true; } MinDecimalValue minDecimalValueAnn = columnAccessor.getAnnotation(MinDecimalValue.class); if (minDecimalValueAnn != null) { minValue = new BigDecimal(minDecimalValueAnn.value()); } else { MinIntValue minIntValueAnn = columnAccessor.getAnnotation(MinIntValue.class); if (minIntValueAnn != null) { minValue = new BigDecimal(minIntValueAnn.value()); } } MaxDecimalValue maxDecimalValueAnn = columnAccessor.getAnnotation(MaxDecimalValue.class); if (maxDecimalValueAnn != null) { maxValue = new BigDecimal(maxDecimalValueAnn.value()); } else { MaxIntValue maxIntValueAnn = columnAccessor.getAnnotation(MaxIntValue.class); if (maxIntValueAnn != null) { maxValue = new BigDecimal(maxIntValueAnn.value()); } } DecimalFormat decimalFormatAnn = columnAccessor.getAnnotation(DecimalFormat.class); if (decimalFormatAnn != null) { decimalFormat = decimalFormatAnn.value(); } DateFormat dateFormatAnn = columnAccessor.getAnnotation(DateFormat.class); if (dateFormatAnn != null) { dateFormat = dateFormatAnn.value(); } }
From source file:com.aestel.chemistry.openEye.fp.Fingerprinter.java
private void writeDictionary() { if (!(mapper instanceof LearningStrcutureCodeMapper)) throw new Error("-writeCodeMap may not be used with this mapper!"); ((LearningStrcutureCodeMapper) mapper).writeDictionary(); }
From source file:edu.utexas.cs.tactex.servercustomers.factoredcustomer.TimeseriesGenerator.java
TimeseriesGenerator(FactoredCustomerService service, TimeseriesStructure structure) { this.service = service; tsStructure = structure;//from w w w.jav a 2 s .co m switch (tsStructure.modelType) { case ARIMA_101x101: initArima101x101(); break; default: throw new Error("Unexpected timeseries model type: " + tsStructure.modelType); } }
From source file:edu.cornell.mannlib.vitro.webapp.controller.MailUsersServlet.java
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { VitroRequest vreq = new VitroRequest(request); String confirmpage = "/confirmUserMail.jsp"; String errpage = "/contact_err.jsp"; String status = null; // holds the error status if (!FreemarkerEmailFactory.isConfigured(vreq)) { status = "This application has not yet been configured to send mail. " + "Email properties must be specified in the configuration properties file."; response.sendRedirect("test?bodyJsp=" + errpage + "&ERR=" + status); return;/*w ww . j av a2 s . c o m*/ } String SPAM_MESSAGE = "Your message was flagged as spam."; boolean probablySpam = false; String spamReason = ""; String originalReferer = (String) request.getSession().getAttribute("commentsFormReferer"); request.getSession().removeAttribute("commentsFormReferer"); if (originalReferer == null) { originalReferer = "none"; // (the following does not support cookie-less browsing:) // probablySpam = true; // status = SPAM_MESSAGE; } else { String referer = request.getHeader("Referer"); //Review how spam works? /*if (referer.indexOf("comments")<0 && referer.indexOf("correction")<0) { probablySpam=true; status = SPAM_MESSAGE ; spamReason = "The form was not submitted from the Contact Us or Corrections page."; }*/ } String formType = vreq.getParameter("DeliveryType"); List<String> deliverToArray = null; int recipientCount = 0; String deliveryfrom = null; // get Individuals that the User mayEditAs deliverToArray = getEmailsForAllUserAccounts(vreq); //Removed all form type stuff b/c recipients pre-configured recipientCount = (deliverToArray == null) ? 0 : deliverToArray.size(); if (recipientCount == 0) { //log.error("recipientCount is 0 when DeliveryType specified as \""+formType+"\""); throw new Error("To establish the Contact Us mail capability the system administrators must " + "specify at least one email address in the current portal."); } // obtain passed in form data with a simple trim on the values String webusername = vreq.getParameter("webusername");// Null.trim(); will give you an exception String webuseremail = vreq.getParameter("webuseremail");//.trim(); String comments = vreq.getParameter("s34gfd88p9x1"); //what does this string signify? //webusername = "hjk54"; //webuseremail = "hjk54@cornell.edu"; //comments = "following are comments"; webusername = webusername.trim(); deliveryfrom = webuseremail; comments = comments.trim(); //Removed spam filtering code StringBuffer msgBuf = new StringBuffer(); // contains the intro copy for the body of the email message String lineSeparator = System.getProperty("line.separator"); // \r\n on windows, \n on unix // from MyLibrary msgBuf.setLength(0); //msgBuf.append("Content-Type: text/html; charset='us-ascii'" + lineSeparator); msgBuf.append("<html>" + lineSeparator); msgBuf.append("<head>" + lineSeparator); msgBuf.append("<style>a {text-decoration: none}</style>" + lineSeparator); msgBuf.append("<title>" + deliveryfrom + "</title>" + lineSeparator); msgBuf.append("</head>" + lineSeparator); msgBuf.append("<body>" + lineSeparator); msgBuf.append("<h4>" + deliveryfrom + "</h4>" + lineSeparator); msgBuf.append("<h4>From: " + webusername + " (" + webuseremail + ")" + " at IP address " + request.getRemoteAddr() + "</h4>" + lineSeparator); //Don't need any 'likely viewing page' portion to be emailed out to the others msgBuf.append(lineSeparator + "</i></p><h3>Comments:</h3>" + lineSeparator); if (comments == null || comments.equals("")) { msgBuf.append("<p>BLANK MESSAGE</p>"); } else { msgBuf.append("<p>" + comments + "</p>"); } msgBuf.append("</body>" + lineSeparator); msgBuf.append("</html>" + lineSeparator); String msgText = msgBuf.toString(); Calendar cal = Calendar.getInstance(); /* outFile.println("<hr/>"); outFile.println(); outFile.println("<p>"+cal.getTime()+"</p>"); outFile.println(); if (probablySpam) { outFile.println("<p>REJECTED - SPAM</p>"); outFile.println("<p>"+spamReason+"</p>"); outFile.println(); } outFile.print( msgText ); outFile.println(); outFile.println(); outFile.flush(); // outFile.close(); */ Session s = FreemarkerEmailFactory.getEmailSession(vreq); //s.setDebug(true); try { // Construct the message MimeMessage msg = new MimeMessage(s); log.debug("trying to send message from servlet"); // Set the from address msg.setFrom(new InternetAddress(webuseremail)); // Set the recipient address if (recipientCount > 0) { InternetAddress[] address = new InternetAddress[recipientCount]; for (int i = 0; i < recipientCount; i++) { address[i] = new InternetAddress(deliverToArray.get(i)); } msg.setRecipients(Message.RecipientType.TO, address); } // Set the subject and text msg.setSubject(deliveryfrom); // add the multipart to the message msg.setContent(msgText, "text/html"); // set the Date: header msg.setSentDate(new Date()); log.debug("sending from servlet"); //if (!probablySpam) Transport.send(msg); // try to send the message via smtp - catch error exceptions } catch (AddressException e) { status = "Please supply a valid email address."; log.debug("Error - status is " + status); } catch (SendFailedException e) { status = "The system was unable to deliver your mail. Please try again later. [SEND FAILED]"; log.error("Error - status is " + status); } catch (MessagingException e) { status = "The system was unable to deliver your mail. Please try again later. [MESSAGING]"; log.error("Error - status is " + status, e); } //outFile.flush(); //outFile.close(); // Redirect to the appropriate confirmation page if (status == null && !probablySpam) { // message was sent successfully response.sendRedirect("test?bodyJsp=" + confirmpage); } else { // exception occurred response.sendRedirect("test?bodyJsp=" + errpage + "&ERR=" + status); } }
From source file:com.cloudbees.sdk.commands.Command.java
@Override public void printHelp(List<String> args) { try {//from w w w . ja v a2s . c o m init("bees"/*TODO:get rid of this*/, args.get(0), args.toArray(new String[args.size()])); } catch (Exception e) { // the use of the exception in the init method doesn't differentiate anticipated problems // (such as user error on parameter values) from unanticipated bugs in code. The former // should be handled without stack trace, later should result in a stack trace. // since we can' differentiate them here, I'm err-ing on the ease of diagnostics and // reporting it as unanticipated bug in code throw new Error(e); } printHelp(); }
From source file:com.genentech.retrival.SDFExport.SDFExporter.java
public SDFExporter(String sqlFile, String rowStmtName, String molStmtName, String outFile, String newLineReplacement, boolean removeSalt, boolean ignoreMismatches) throws IOException { start = System.currentTimeMillis(); this.newLineReplacement = newLineReplacement; File sqlFILE = new File(sqlFile); if (!sqlFILE.exists()) throw new IOException(sqlFile + " not found!"); rowStmt = SQLStatement.createFromFile(sqlFILE, rowStmtName); rowSel = Selecter.factory(rowStmt);/*from ww w . ja v a2s . co m*/ rowSel.setFetchSize(200); this.ignoreMisMatches = ignoreMismatches; this.removeSalt = removeSalt; if (removeSalt) saltRemover = SaltRemover.createDefault(); SQLStatement molStmt = rowStmt; if (molStmtName != null) { molStmt = SQLStatement.createFromFile(sqlFILE, molStmtName); molSel = Selecter.factory(molStmt); } else { molSel = null; } if (MOLFPattern.matcher(molStmt.toString()).find()) { molType = "MOLFILE"; smiTalk = null; } else if (SMIPattern.matcher(molStmt.toString()).find()) { molType = "SMILES"; smiTalk = new SmiTalk(); } else { throw new Error("Could not identify molecule format:\n" + molStmt.toString()); } if (outFile == null || outFile.equalsIgnoreCase(".sdf")) out = System.out; else out = new PrintStream(outFile); }
From source file:com.google.walkaround.wave.server.attachment.AttachmentMetadataHandler.java
private void doRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException { Map<AttachmentId, Optional<AttachmentMetadata>> result = attachments.getMetadata(getIds(req), MAX_REQUEST_TIME_MS);// ww w . ja v a 2 s . co m JSONObject json = new JSONObject(); try { for (Entry<AttachmentId, Optional<AttachmentMetadata>> entry : result.entrySet()) { JSONObject metadata = new JSONObject( entry.getValue().isPresent() ? entry.getValue().get().getMetadataJsonString() : INVALID_ATTACHMENT_ID_METADATA_STRING); String queryParams = "attachment=" + UriEscapers.uriQueryStringEscaper(false).escape(entry.getKey().getId()); metadata.put("url", "/download?" + queryParams); metadata.put("thumbnailUrl", "/thumbnail?" + queryParams); json.put(entry.getKey().getId(), metadata); } } catch (JSONException e) { throw new Error(e); } ServletUtil.writeJsonResult(resp.getWriter(), json.toString()); }
From source file:hudson.plugins.ec2.AmazonEC2Cloud.java
@Override public URL getS3EndpointUrl() { try {// w w w.j ava 2 s . c o m return new URL("https://" + getRegion() + ".s3.amazonaws.com/"); } catch (MalformedURLException e) { throw new Error(e); // Impossible } }
From source file:com.l2jserver.service.core.logging.TruncateToZipFileAppender.java
/** * This method creates archive with file instead of deleting it. * //w w w .ja v a 2 s . co m * @param file * file to truncate */ protected void truncate(File file) { LogLog.debug("Compression of file: " + file.getAbsolutePath() + " started."); // Linux systems doesn't provide file creation time, so we have to hope // that log files // were not modified manually after server starup // We can use here Windowns-only solution but that suck :( if (FileUtils.isFileOlder(file, ManagementFactory.getRuntimeMXBean().getStartTime())) { File backupRoot = new File(getBackupDir()); if (!backupRoot.exists() && !backupRoot.mkdirs()) { throw new Error("Can't create backup dir for backup storage"); } SimpleDateFormat df; try { df = new SimpleDateFormat(getBackupDateFormat()); } catch (Exception e) { throw new Error("Invalid date formate for backup files: " + getBackupDateFormat(), e); } String date = df.format(new Date(file.lastModified())); File zipFile = new File(backupRoot, file.getName() + "." + date + ".zip"); ZipOutputStream zos = null; FileInputStream fis = null; try { zos = new ZipOutputStream(new FileOutputStream(zipFile)); ZipEntry entry = new ZipEntry(file.getName()); entry.setMethod(ZipEntry.DEFLATED); entry.setCrc(FileUtils.checksumCRC32(file)); zos.putNextEntry(entry); fis = FileUtils.openInputStream(file); byte[] buffer = new byte[1024]; int readed; while ((readed = fis.read(buffer)) != -1) { zos.write(buffer, 0, readed); } } catch (Exception e) { throw new Error("Can't create zip file", e); } finally { if (zos != null) { try { zos.close(); } catch (IOException e) { // not critical error LogLog.warn("Can't close zip file", e); } } if (fis != null) { try { // not critical error fis.close(); } catch (IOException e) { LogLog.warn("Can't close zipped file", e); } } } if (!file.delete()) { throw new Error("Can't delete old log file " + file.getAbsolutePath()); } } }