List of usage examples for java.lang Exception Exception
public Exception(Throwable cause)
From source file:com.rathink.p.user.action.UserAction.java
public String dispatcher() throws Exception { if (!"saas".equals(LicenseManagerImpl.getLicense().getMode())) { LicenseManagerImpl.licenseDate(); int flag = LicenseManagerImpl.getLicense().getPassed(); if (flag == -1) { throw new Exception(getText("System.propertyFile.illegal")); } else if (flag == -2) { throw new Exception(getText("System.propertyFile.overdue")); } else if (flag == -3) { throw new Exception(getText("System.propertyFile.noFindKey")); } else if (flag == -4) { throw new Exception(getText("System.propertyFile.updateKey")); }//w w w .j ava 2s . com } if (PConst.USER_TYPE_TEACHER == myUser.getType()) { if (myUser.getType() == PConst.USER_TYPE_DELETE) { throw new Exception(getText("user.delete.error")); } } return SUCCESS; }
From source file:Main.java
/** * Returns the text content of the provided element as is. If multiple text * DOM nodes are present, they are concatenated together. * //from w w w.ja v a 2 s . co m * @param element The element that contains the desired text content. * @return The text content of the given element. * @throws Exception If an exception occurs during the traversal of the DOM * objects. */ public static String getElementTextData(Element element) throws Exception { if (!element.hasChildNodes()) { throw new Exception("Element has no children."); } Node n = element.getFirstChild(); if ((n.getNodeType() != Node.TEXT_NODE) && (n.getNodeType() != Node.CDATA_SECTION_NODE)) { // must be a textual node // for now throw an exception, but later need to just skip this module and // resume initialization throw new Exception("Element child node is not textual."); } CharacterData value = (CharacterData) n; return value.getData(); }
From source file:Main.java
/** * Transform node./*from w ww . j av a 2 s . co m*/ * * @param node * the node * @param encoding * the encoding * @param removeXmlHeader * the remove xml header * @param result * the result * @throws Exception * the exception */ private static void transformNode(Node node, String encoding, boolean removeXmlHeader, StreamResult result) throws Exception { TransformerFactory transformerFactory = null; Transformer transformer = null; DOMSource source = null; try { transformerFactory = TransformerFactory.newInstance(); if (transformerFactory == null) { throw new Exception("TransformerFactory error"); } transformer = transformerFactory.newTransformer(); if (transformer == null) { throw new Exception("Transformer error"); } transformer.setOutputProperty(OutputKeys.ENCODING, encoding); if (removeXmlHeader) { transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); } else { transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); } source = new DOMSource(node); transformer.transform(source, result); } catch (TransformerFactoryConfigurationError e) { throw new Exception("TransformerFactoryConfigurationError", e); } catch (TransformerConfigurationException e) { throw new Exception("TransformerConfigurationException", e); } catch (TransformerException e) { throw new Exception("TransformerException", e); } }
From source file:br.com.s2it.snakes.services.CarService.java
public Car save(Car car) throws Exception { if (car == null || car.getLicensePlate() == null || car.getMileage() == null || car.getModel() == null || car.getName() == null || car.getParkingSpace() == null || car.getUnit() == null || car.getYear() == null) {/*from w w w . j a v a2 s . c om*/ throw new Exception("null_params"); } car = repository.save(car); return car; }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.ChildVClassesWithParent.java
public ChildVClassesWithParent(String classUri) throws Exception { super();/*ww w. j a v a 2s . co m*/ if (classUri == null || classUri.equals("")) throw new Exception("vclassUri not set"); this.classUri = classUri; }
From source file:Main.java
/** * @param rawValue//from w ww .j a va 2s .c om * @return * @throws Exception */ public static long decodeRawValueToSingleLong(String rawValue) throws Exception { String[] values = getSingleValue(rawValue); if ("l".equals(values[0])) return Long.parseLong(values[1]); throw new Exception("Data type is not 'l' (long), found '" + values[0] + "'"); }
From source file:com.clustercontrol.jobmanagement.util.JobmapIconImageUtil.java
/** * ???/*from ww w . j av a 2 s.co m*/ * * @param filepath * @throws Exception */ public static byte[] getImageFileData(String filepath) throws Exception { // ? byte[] filedata = getFileData(filepath); // ?? ImageData imageData = getImageData(filedata); if (imageData.width != ICON_WIDTH || imageData.height != ICON_WIDTH) { String[] args = { Integer.toString(ICON_WIDTH), Integer.toString(ICON_HEIGHT) }; throw new Exception(Messages.getString("message.job.141", args)); } return filedata; }
From source file:com.wyp.module.cache.LicenseCacheDao.java
@Override public int insert(License entity) { redisTemplate.boundValueOps("123").set("TEST_XXX"); redisTemplate.boundValueOps("age").set("11"); // ?/*from ww w . j ava2 s .co m*/ for (int i = 0; i < 5; i++) { if (i == 3) { throw new RedisSystemException("dsd", new Exception("myself exception.....")); } } return 0; }
From source file:com.ah.util.http.HttpFileTransferUtil.java
/** * upload file to ls//from w ww .jav a 2 s .c o m * @param fileName - * @param urlParam - * @throws Exception - */ public static void uploadFileToLS(String fileName, String urlParam) throws Exception { HttpCommunication hc = uploadSettings(urlParam); File file = new File(fileName); HttpResponse response = hc.uploadFile(null, file); if (response.getStatusLine().getStatusCode() != 200) { throw new Exception( "Fail to upload file " + fileName + ", statuscode=" + response.getStatusLine().getStatusCode() + ",message=" + response.getStatusLine().getReasonPhrase()); } }
From source file:circleplus.app.utils.JSONUtils.java
@SuppressWarnings("unchecked") public static BaseType consume(Parser<? extends BaseType> parser, String content) throws Exception { if (D)/*from ww w .j ava2 s .c om*/ Log.d(TAG, "http response: " + content); try { JSONObject json = new JSONObject(content); Iterator<String> it = (Iterator<String>) json.keys(); if (it.hasNext()) { String key = it.next(); // we had checked network error on http level // so the parser here must be instance of StatusParser if ("error".equals(key)) { return parser.parse(json.getJSONObject(key)); } else { Object obj = json.get(key); if (obj instanceof JSONArray) { return parser.parse((JSONArray) obj); } else { return parser.parse((JSONObject) obj); } } } else { throw new Exception("Error parsing JSON response, " + "object has no single child key."); } } catch (JSONException ex) { throw new Exception("Error parsing JSON response: " + ex.getMessage()); } }