List of usage examples for java.lang Exception getStackTrace
public StackTraceElement[] getStackTrace()
From source file:com.yuntongxun.ecdemo.storage.IMessageSqlManager.java
/** * ?/*www .j a v a 2 s . c o m*/ * * @param msg * @return */ public static int updateIMessageDownload(ECMessage msg) { if (msg == null || TextUtils.isEmpty(msg.getMsgId())) { return -1; } int row = -1; ContentValues values = new ContentValues(); try { String where = IMessageColumn.MESSAGE_ID + " = '" + msg.getMsgId() + "'"; ECFileMessageBody msgBody = (ECFileMessageBody) msg.getBody(); values.put(IMessageColumn.FILE_PATH, msgBody.getLocalUrl()); values.put(IMessageColumn.USER_DATA, msg.getUserData()); if (msg.getType() == ECMessage.Type.VOICE) { int voiceTime = DemoUtils.calculateVoiceTime(msgBody.getLocalUrl()); values.put(IMessageColumn.DURATION, voiceTime); } row = getInstance().sqliteDB().update(DatabaseHelper.TABLES_NAME_IM_MESSAGE, values, where, null); // notifyChanged(msgId); } catch (Exception e) { LogUtil.e(TAG + " " + e.toString()); e.getStackTrace(); } finally { if (values != null) { values.clear(); values = null; } } return row; }
From source file:com.qmetry.qaf.automation.testng.pro.QAFTestNGListener.java
public void onFinish(ISuite suite) { try {/* w w w . ja v a2s. c o m*/ generateTestFailedXML(suite); } catch (Exception e) { logger.debug(e.getStackTrace()); logger.info("Unable to create testng-failed-qas.xml"); } }
From source file:com.smartitengineering.util.bean.PropertiesLocator.java
public boolean loadProperties(Properties props) throws IOException { boolean resourceFound = false; if (getSmartLocations() != null) { for (int i = 0; i < getSmartLocations().length; i++) { final String location = getSmartLocations()[i]; InputStream is = null; String context = getResourceContext(); if (StringUtils.isNotEmpty(context)) { if (!context.endsWith("/")) { context = new StringBuilder(context).append('/').toString(); }//w w w.j a va 2 s. c o m } String fileName = new StringBuilder(context).append(location).toString(); if (StringUtils.isEmpty(fileName)) { continue; } try { Resource resource; if (isDefaultSearchEnabled()) { String resourceName = new StringBuilder(fileName).append(getDefaultResourceSuffix()) .toString(); String resourcePath = new StringBuilder(CLASSPATH_RESOURCE_PREFIX).append(resourceName) .toString(); resource = ResourceFactory.getResource(resourcePath); is = attemptToLoadResource(props, resource); resourceFound = closeInputStream(is) || resourceFound; } if (isClasspathSearchEnabled()) { String resourcePath = new StringBuilder(CLASSPATH_RESOURCE_PREFIX).append(fileName) .toString(); resource = ResourceFactory.getResource(resourcePath); is = attemptToLoadResource(props, resource); resourceFound = closeInputStream(is) || resourceFound; } if (isCurrentDirSearchEnabled()) { String parent = System.getProperty("user.dir"); resourceFound = attempToReadRsrcFromFile(parent, fileName, resourceFound, props) || resourceFound; } if (isUserHomeSearchEnabled()) { String parent = System.getProperty("user.home"); resourceFound = attempToReadRsrcFromFile(parent, fileName, resourceFound, props) || resourceFound; } if (getSearchLocations() != null) { for (String searchLocation : getSearchLocations()) { if (StringUtils.isNotEmpty(StringUtils.trim(searchLocation))) { resourceFound = attempToReadRsrcFromFile(searchLocation, fileName, resourceFound, props) || resourceFound; } } } } catch (Exception ex) { IOException exception = new IOException(); exception.setStackTrace(ex.getStackTrace()); throw exception; } finally { closeInputStream(is); } } } return resourceFound; }
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.FauxPropertyRetryController.java
@Override public void doPost(HttpServletRequest req, HttpServletResponse response) { if (!isAuthorizedToDisplayPage(req, response, SimplePermission.EDIT_ONTOLOGY.ACTION)) { return;/* www . j a v a 2 s.c om*/ } // create an EditProcessObject for this and put it in the session EditProcessObject epo = super.createEpo(req); // Populate it. EpoPopulator populator = new EpoPopulator(req, epo); populator.populate(); req.setAttribute("bodyJsp", "/templates/edit/formBasic.jsp"); req.setAttribute("colspan", "5"); req.setAttribute("formJsp", "/templates/edit/specific/fauxProperty_retry.jsp"); req.setAttribute("scripts", "/templates/edit/formBasic.js"); req.setAttribute("title", "Faux Property Editing Form"); req.setAttribute("_action", epo.getAction()); setRequestAttributes(req, epo); try { RequestDispatcher rd = req.getRequestDispatcher(Controllers.BASIC_JSP); rd.forward(req, response); } catch (Exception e) { log.error("Could not forward to view."); log.error(e.getMessage()); log.error(e.getStackTrace()); } }
From source file:com.esri.geoevent.solutions.adapter.cot.MessageParser.java
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { try {/*from www. j av a 2s .co m*/ if (qName == null) return; if (messageLevel == MessageLevel.root && (qName.equalsIgnoreCase(MESSAGES) || qName.equalsIgnoreCase("geomessages"))) { messageLevel = MessageLevel.inMessages; } else if (messageLevel == MessageLevel.inMessages && (qName.equalsIgnoreCase(MESSAGE) || qName.equalsIgnoreCase("geomessage"))) { messageLevel = MessageLevel.inMessage; } else if (messageLevel == MessageLevel.inMessage) { messageLevel = MessageLevel.inAttribute; attribute = ""; attributeName = qName; } else if (messageLevel == MessageLevel.inAttribute) { throw new SAXException("Problem parsing message, cannot handle nested attributes. (" + qName + " inside " + attributeName + ")"); } else if (qName.equalsIgnoreCase("event")) { // Event element was found. Store all available CoT attributes. for (int i = 0; attributes.getLength() > i; i++) { String l = attributes.getLocalName(i); String q = attributes.getQName(i); String name = null; if (l.isEmpty()) { name = q; } else { name = l; } if (name.equalsIgnoreCase("how")) { this.how = attributes.getValue(i); } else if (name.equalsIgnoreCase("opex")) { this.opex = attributes.getValue(i); } else if (name.equalsIgnoreCase("qos")) { this.qos = attributes.getValue(i); } else if (name.equalsIgnoreCase("type")) { this.type = attributes.getValue(i); } else if (name.equalsIgnoreCase("uid")) { this.uid = attributes.getValue(i); } else if (name.equalsIgnoreCase("stale")) { this.stale = attributes.getValue(i); } else if (name.equalsIgnoreCase("start")) { this.start = attributes.getValue(i); } else if (name.equalsIgnoreCase("time")) { this.time = attributes.getValue(i); } else if (name.equalsIgnoreCase("version")) { this.version = attributes.getValue(i); } else if (name.equalsIgnoreCase("access")) { this.access = attributes.getValue(i); } } } else if (!inDetails && qName.equalsIgnoreCase("detail")) { // <detail> element started tabLevel++; inDetails = true; detail.append("\n" + makeTabs(tabLevel) + "<eventWrapper><detail"); // (NOTE: detail should NOT have any attributes but search just // in case) for (int i = 0; attributes.getLength() > i; i++) { detail.append("\n" + makeTabs(tabLevel + 1) + attributes.getLocalName(i) + "=" + "\"" + attributes.getValue(i) + "\""); } // close the tag detail.append(">"); } else if (inDetails && !qName.equalsIgnoreCase("detail")) { // some new child element inside the Detail section tabLevel++; detail.append("\n" + makeTabs(tabLevel) + "<" + qName); // search for any attributes for (int i = 0; attributes.getLength() > i; i++) { String l = attributes.getLocalName(i); String q = attributes.getQName(i); String name = null; if (l.isEmpty()) { name = q; } else { name = l; } detail.append( "\n" + makeTabs(tabLevel + 1) + name + "=" + "\"" + attributes.getValue(i) + "\""); } // close the tag detail.append(">"); } else if (!inDetails && qName.equalsIgnoreCase("point")) { // <point> element started tabLevel++; point.append("\n" + makeTabs(tabLevel) + "<point"); // search for any attributes for (int i = 0; attributes.getLength() > i; i++) { String l = attributes.getLocalName(i); String q = attributes.getQName(i); String name = null; if (l.isEmpty()) { name = q; } else { name = l; } point.append("\n" + makeTabs(tabLevel + 1) + name + "=" + "\"" + attributes.getValue(i) + "\""); } // close the tag point.append(" />"); tabLevel--; } } catch (Exception e) { LOG.error(e); LOG.error(e.getStackTrace()); } }
From source file:org.apromore.service.pql.impl.PQLServiceImpl.java
public List<String> runAPQLQuery(String queryPQL, List<String> IDs, String userID) { //Set<String> idNets=new HashSet<>(); List<String> results = Collections.emptyList(); IPQLAPI api = pqlBean.getApi();//w ww .j a v a 2 s . c o m LOGGER.error("-----------PQLAPI: " + api); LOGGER.error("----------- query: " + queryPQL); LOGGER.error("----------- IDs: " + IDs); LOGGER.error("----------- user: " + userID); try { PQLQueryResult pqlQueryResult = api.query(queryPQL, new HashSet<>(IDs)); if (pqlQueryResult.getNumberOfParseErrors() != 0) { results = pqlQueryResult.getParseErrorMessages(); } else {//risultati LOGGER.error("-----------IDS PQLServiceImpl" + IDs); map = pqlQueryResult.getTaskMap(); LinkedList<PQLTask> tasks = new LinkedList<>(map.values()); /* idNets=new HashSet<>(IDs); idNets=api.checkLastQuery(idNets); results.addAll(idNets); */ results = new LinkedList<>(pqlQueryResult.getSearchResults()); LOGGER.error("-----------QUERYAPQL ESATTA " + results); } } catch (Exception e) { LOGGER.error("-----------ERRORRE: " + e.toString()); for (StackTraceElement ste : e.getStackTrace()) LOGGER.info("ERRORE6: " + ste.getClassName() + " " + ste.getMethodName() + " " + ste.getLineNumber() + " " + ste.getFileName()); } return results; }
From source file:com.infinities.skyport.async.impl.AsyncHandler.java
private Exception throwCause(Exception e, boolean combineStackTraces) throws Exception { Throwable cause = e.getCause(); if (cause == null) { throw e;/* ww w . ja v a 2 s. c o m*/ } if (combineStackTraces) { StackTraceElement[] combined = ObjectArrays.concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class); cause.setStackTrace(combined); } if (cause instanceof Exception) { throw (Exception) cause; } if (cause instanceof Error) { throw (Error) cause; } // The cause is a weird kind of Throwable, so throw the outer // exception. throw e; }
From source file:de.Keyle.MyPet.skill.skilltreeloader.SkillTreeLoaderJSON.java
protected void loadSkillTree(ConfigurationJSON jsonConfiguration, SkillTreeMobType skillTreeMobType) { JSONArray skilltreeList = (JSONArray) jsonConfiguration.getJSONObject().get("Skilltrees"); for (Object st_object : skilltreeList) { SkillTree skillTree;//from www .j a va 2s .c om int place; try { JSONObject skilltreeObject = (JSONObject) st_object; skillTree = new SkillTree((String) skilltreeObject.get("Name")); place = Integer.parseInt(String.valueOf(skilltreeObject.get("Place"))); if (skilltreeObject.containsKey("Inherits")) { skillTree.setInheritance((String) skilltreeObject.get("Inherits")); } if (skilltreeObject.containsKey("Permission")) { skillTree.setPermission((String) skilltreeObject.get("Permission")); } if (skilltreeObject.containsKey("Display")) { skillTree.setDisplayName((String) skilltreeObject.get("Display")); } if (skilltreeObject.containsKey("Description")) { JSONArray descriptionArray = (JSONArray) skilltreeObject.get("Description"); for (Object lvl_object : descriptionArray) { skillTree.addDescriptionLine(String.valueOf(lvl_object)); } } JSONArray levelList = (JSONArray) skilltreeObject.get("Level"); for (Object lvl_object : levelList) { JSONObject levelObject = (JSONObject) lvl_object; int thisLevel = Integer.parseInt(String.valueOf(levelObject.get("Level"))); SkillTreeLevel newLevel = skillTree.addLevel(thisLevel); if (levelObject.containsKey("Message")) { String message = (String) levelObject.get("Message"); newLevel.setLevelupMessage(message); } JSONArray skillList = (JSONArray) levelObject.get("Skills"); for (Object skill_object : skillList) { JSONObject skillObject = (JSONObject) skill_object; String skillName = (String) skillObject.get("Name"); JSONObject skillPropertyObject = (JSONObject) skillObject.get("Properties"); if (SkillsInfo.getSkillInfoClass(skillName) != null) { ISkillInfo skill = SkillsInfo.getNewSkillInfoInstance(skillName); if (skill != null) { SkillProperties sp = skill.getClass().getAnnotation(SkillProperties.class); if (sp != null) { TagCompound propertiesCompound = skill.getProperties(); for (int i = 0; i < sp.parameterNames().length; i++) { String propertyName = sp.parameterNames()[i]; NBTdatatypes propertyType = sp.parameterTypes()[i]; if (!propertiesCompound.getCompoundData().containsKey(propertyName) && skillPropertyObject.containsKey(propertyName)) { String value = String.valueOf(skillPropertyObject.get(propertyName)); switch (propertyType) { case Short: if (Util.isShort(value)) { propertiesCompound.getCompoundData().put(propertyName, new TagShort(Short.parseShort(value))); } break; case Int: if (Util.isInt(value)) { propertiesCompound.getCompoundData().put(propertyName, new TagInt(Integer.parseInt(value))); } break; case Long: if (Util.isLong(value)) { propertiesCompound.getCompoundData().put(propertyName, new TagLong(Long.parseLong(value))); } break; case Float: if (Util.isFloat(value)) { propertiesCompound.getCompoundData().put(propertyName, new TagFloat(Float.parseFloat(value))); } break; case Double: if (Util.isDouble(value)) { propertiesCompound.getCompoundData().put(propertyName, new TagDouble(Double.parseDouble(value))); } break; case Byte: if (Util.isByte(value)) { propertiesCompound.getCompoundData().put(propertyName, new TagByte(Byte.parseByte(value))); } break; case Boolean: if (value == null || value.equalsIgnoreCase("") || value.equalsIgnoreCase("off") || value.equalsIgnoreCase("false")) { propertiesCompound.getCompoundData().put(propertyName, new TagByte(false)); } else if (value.equalsIgnoreCase("on") || value.equalsIgnoreCase("true")) { propertiesCompound.getCompoundData().put(propertyName, new TagByte(true)); } break; case String: propertiesCompound.getCompoundData().put(propertyName, new TagString(value)); break; } } } skill.setProperties(propertiesCompound); skill.setDefaultProperties(); skillTree.addSkillToLevel(thisLevel, skill); } } } } } skillTreeMobType.addSkillTree(skillTree, place); } catch (Exception e) { DebugLogger.info("Problem in" + skillTreeMobType.getMobTypeName()); DebugLogger.info(Arrays.toString(e.getStackTrace())); e.printStackTrace(); DebugLogger.printThrowable(e); MyPetLogger.write(ChatColor.RED + "Error in " + skillTreeMobType.getMobTypeName().toLowerCase() + ".json -> Skilltree not loaded."); } } }
From source file:de.fau.amos4.util.Lodas.java
public String generate() { try {/*www . j a v a 2s. co m*/ StringBuilder sb = new StringBuilder(); sb.append(title("Allgemein")).append(sectionAllgemein()).append(divider()) .append(title("Satzbeschreibung")).append(sectionSatzbeschreibung()).append(divider()) .append(title("Stammdaten")).append(sectionStammdaten()); return sb.toString(); } catch (Exception ex) { return "Export failed. \nMessage:\n" + ex.getMessage() + "\nType:\n" + ex.toString() + "\nStack:\n" + ex.getStackTrace(); } }
From source file:org.openmrs.module.webservices.rest.web.RestUtilTest.java
/** * @see RestUtil#wrapErrorResponse(Exception,String) * @verifies set stack trace code if available *//*w w w. j av a 2s . co m*/ @Test public void wrapErrorResponse_shouldSetStackTraceCodeAndDetailIfAvailable() throws Exception { Exception mockException = Mockito.mock(Exception.class); Mockito.when(mockException.getMessage()).thenReturn("exceptionmessage"); StackTraceElement ste = new StackTraceElement("org.mypackage.myclassname", "methodName", "fileName", 149); Mockito.when(mockException.getStackTrace()).thenReturn(new StackTraceElement[] { ste }); SimpleObject returnObject = RestUtil.wrapErrorResponse(mockException, "wraperrorresponsemessage"); LinkedHashMap errorResponseMap = (LinkedHashMap) returnObject.get("error"); Assert.assertEquals("org.mypackage.myclassname:149", errorResponseMap.get("code")); }