List of usage examples for java.lang Throwable Throwable
public Throwable()
From source file:com.momock.util.Logger.java
public static void error(Throwable e) { if (!enabled || logLevel > LEVEL_ERROR) return;//w w w. ja v a 2 s . c o m String msg = e.getMessage() + " : " + getStackTrace(e); Throwable t = new Throwable(); StackTraceElement trace = t.getStackTrace()[1]; android.util.Log.e(logName, msg + " @ " + getSourceInfo(trace)); checkLogFile(); logStream.println(getLog("ERROR", msg)); logStream.flush(); event.fireEvent(null, new LogEventArgs(null, e)); }
From source file:com.alipay.vbizplatform.web.controller.MyCarManageController.java
/** * ??/*from w ww . j ava 2 s. c o m*/ * @param request * @param response * @return */ @RequestMapping(value = "/portal") public String portal(HttpServletRequest request, HttpServletResponse response) { UserModel userModel = super.getUserInfo(request); /** PrintWriter out = null; try { response.setCharacterEncoding("UTF-8"); out = response.getWriter(); StringBuilder loading = new StringBuilder(); loading.append("<script type=\"text/javascript\" src=\"../js/portal.js\"></script>"); loading.append("<script type=\"text/javascript\">"); loading.append("document.write(_LoadingHtml);"); loading.append("</script>"); out.println(loading.toString()); out.flush(); } catch (Exception e) { logger.error("loading", e); } **/ // ??banner long startTime = System.currentTimeMillis(); String banner = super.invokeVelocityDynamicCreateHtml("banner/sample/topbars.utf8.vm"); request.setAttribute("banner", banner); // 1????? try { logger.info("userModel={}", userModel != null ? userModel.getUid() : ""); /**** test_begin ****/ if (userModel == null) { userModel = new UserModel(); userModel.setUid("2015052100077120770" + RandomUtil.getFixLenthString(3)); // userModel.setUid("2015052100077000000000120774"); userModel.setPhoneNumber("13810331329"); userModel.setRealName(""); userModel.setCertNo("2301012345678905678"); request.getSession().setAttribute(Constant.ALIPAY_USER_SESSION_KEY, userModel); } request.setAttribute("userMap", userModel); logger.info("userModel={}", JSONObject.toJSON(userModel)); /***** test_end *******/ // 2???? List<Map<String, Object>> vehicleList = myCarManageService.queryVehicleListByUid(userModel.getUid()); Map<String, Object> myCar = null; String viNumber = null; // 3?? if (vehicleList != null && vehicleList.size() > 1) { // ??24? spyMemcachedClient.set(userModel.getUid() + "_myCarList", Constant.MEMCACHED_SAVETIME_24, vehicleList); for (Map<String, Object> car : vehicleList) { if (car.get("defaultStatus") instanceof Integer && Integer.parseInt(car.get("defaultStatus").toString()) == 1) { myCar = car; viNumber = String.valueOf(myCar.get("viNumber")); } } if (myCar == null) { // myCar = vehicleList.get(0); viNumber = String.valueOf(myCar.get("viNumber")); } } else if (vehicleList != null && vehicleList.size() == 1) { myCar = vehicleList.get(0); viNumber = String.valueOf(myCar.get("viNumber")); } // 4??? request.setAttribute("myCar", myCar); // 5? Map<String, String> cityMap = null; try { cityMap = ownerMessage.queryResidentcity(userModel.getUid()); } catch (Exception e) { if (logger.isErrorEnabled()) logger.error("sofa?", e); } if (cityMap == null) { // cookie? Cookie cityName = CookieTool.getCookieByName(request, "aliPay_residentCityName"); Cookie cityCode = CookieTool.getCookieByName(request, "aliPay_residentCityCode"); if (cityName != null) { cityMap = new HashMap<String, String>(); cityMap.put("resident_city_name", URLDecoder.decode(cityName.getValue(), "UTF-8")); cityMap.put("resident_city_code", URLDecoder.decode(cityCode.getValue(), "UTF-8")); } } request.setAttribute("cityMap", cityMap); // 6? String cityCode = "330100"; //? if (cityMap != null && !cityMap.isEmpty()) { cityCode = cityMap.get("resident_city_code"); //?session start Object userLocaObject = request.getSession() .getAttribute(Constant.ALIPAY_USER_LOCATION_SESSION_KEY); Map<String, String> userLoca = null; if (null != userLocaObject) { userLoca = (Map<String, String>) userLocaObject; } else { userLoca = new HashMap<String, String>(); } userLoca.put("residentCityCode", cityCode); userLoca.put("residentCityName", cityMap.get("resident_city_name")); request.getSession().setAttribute(Constant.ALIPAY_USER_LOCATION_SESSION_KEY, userLoca); //end } Map<String, String> userMap = new HashMap<String, String>(); userMap.put("userId", userModel.getUid()); List<Map<String, Object>> categoryAppList = ownerMessage.queryCategoryApp(userMap, cityCode, viNumber); request.setAttribute("categoryAppList", categoryAppList); // 7??? int unReadMessage = 0; try { unReadMessage = ownerMessage.messageGetUnreadcount(userModel.getUid()); } catch (Exception e) { logger.error("??sofa?", e); } if (unReadMessage > 0) { // ? try { List<Map<String, Object>> messageList = ownerMessage.messageBatchquery(userModel.getUid(), false, 1, 1); if (messageList != null && !messageList.isEmpty()) { request.setAttribute("message", messageList.get(0)); } } catch (Exception e) { logger.error("?sofa?", e); } } else if (cityMap != null && cityMap.get("resident_city_code") != null) { try { String limitedContent = ownerMessage.queryLimitedLineContent(cityMap.get("resident_city_code"), new Date()); request.setAttribute("limitedContent", limitedContent); } catch (Exception e) { logger.error("??sofa?", e); } } //8??? String userLastTimeGPS = spyMemcachedClient.get(userModel.getUid() + "_LastTimeGPS"); request.setAttribute("lastTimeGPS", userLastTimeGPS); } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error("??", e); } super.redirectErrorPage("BUSY-ERR", "??", null, null, response); logUtil.log(new Throwable(), "PORTAL", userModel.getUid(), MethodCallResultEnum.EXCEPTION, null, "??", startTime); return null; } logUtil.log(new Throwable(), "PORTAL", userModel.getUid(), MethodCallResultEnum.SUCCESS, null, "??", startTime); return "/page/portal"; }
From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java
/** * Error./* w ww . j a v a2 s . c o m*/ * * @param msg The error message * @see java.util.logging.Level#SEVERE */ public void error(String msg) { StackTraceElement[] elements = new Throwable().getStackTrace(); logp(Level.SEVERE, elements[1].getClassName(), elements[1].getMethodName(), String.valueOf(msg)); }
From source file:com.momock.util.Logger.java
public static void check(boolean condition, String msg) { if (!condition) { if (!enabled || logLevel > LEVEL_ERROR) return; if (msg == null) msg = ""; Throwable t = new Throwable(); StackTraceElement trace = t.getStackTrace()[1]; android.util.Log.e(logName, msg + " @ " + getSourceInfo(trace)); checkLogFile();/* w w w .j a v a 2 s.c o m*/ logStream.println(getLog("ASSERT", msg)); logStream.flush(); throw new RuntimeException(msg); } }
From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java
/** * Error./*from ww w . j ava 2 s.c o m*/ * * @param message The error message * @param cause The cause of the error * @see java.util.logging.Level#SEVERE */ public void error(Object message, Throwable cause) { StackTraceElement[] elements = new Throwable().getStackTrace(); logp(Level.SEVERE, elements[1].getClassName(), elements[1].getMethodName(), String.valueOf(message), cause); }
From source file:com.wavemaker.runtime.data.spring.SpringDataServiceManager.java
private void logStackTrace() { txLogger.debug(StringUtils.toString(new Throwable())); }
From source file:com.zimbra.cs.db.DbPool.java
public static DbConnection getConnection(Mailbox mbox) throws ServiceException { if (!isInitialized()) { throw ServiceException.FAILURE("Database connection pool not initialized.", null); }//from ww w . jav a 2s .c o m Integer mboxId = mbox != null ? mbox.getId() : -1; //-1 == zimbra db and/or initialization where mbox isn't known yet try { Db.getInstance().preOpen(mboxId); long start = ZimbraPerf.STOPWATCH_DB_CONN.start(); // If the connection pool is overutilized, warn about potential leaks PoolingDataSource pool = getPool(); checkPoolUsage(); Connection dbconn = null; DbConnection conn = null; try { dbconn = pool.getConnection(); if (dbconn.getAutoCommit() != false) dbconn.setAutoCommit(false); // We want READ COMMITTED transaction isolation level for duplicate // handling code in BucketBlobStore.newBlobInfo(). if (Db.supports(Db.Capability.READ_COMMITTED_ISOLATION)) dbconn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); conn = new DbConnection(dbconn, mboxId); Db.getInstance().postOpen(conn); } catch (SQLException e) { try { if (dbconn != null && !dbconn.isClosed()) dbconn.close(); } catch (SQLException e2) { ZimbraLog.sqltrace.warn("DB connection close caught exception", e); } throw ServiceException.FAILURE("getting database connection", e); } // If we're debugging, update the counter with the current stack trace if (ZimbraLog.dbconn.isDebugEnabled()) { Throwable t = new Throwable(); conn.setStackTrace(t); String stackTrace = SystemUtil.getStackTrace(t); synchronized (sConnectionStackCounter) { sConnectionStackCounter.increment(stackTrace); } } if (mbox != null) Db.registerDatabaseInterest(conn, mbox); ZimbraPerf.STOPWATCH_DB_CONN.stop(start); return conn; } catch (ServiceException se) { //if connection open fails unlock Db.getInstance().abortOpen(mboxId); throw se; } }
From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java
/** * Error./*from w w w .ja v a2 s .c o m*/ * * @param cause The cause of the error * @see java.util.logging.Level#SEVERE */ public void error(Throwable cause) { StackTraceElement[] elements = new Throwable().getStackTrace(); logp(Level.SEVERE, elements[1].getClassName(), elements[1].getMethodName(), cause.getLocalizedMessage(), cause); }
From source file:com.seleniumtests.ut.reporter.TestTestStep.java
@Test(groups = { "ut" }) public void testTestStepEncodeXmlExceptionKept() { TestStep step = new TestStep("step1 \"'<>&", null, new ArrayList<>()); step.setActionException(new Throwable()); TestStep encodedTestStep = step.encode("xml"); Assert.assertNotNull(encodedTestStep.getActionException()); }
From source file:org.apache.ranger.biz.RangerBizUtil.java
void deleteObject(XXDBBase obj) { AbstractBaseResourceService<?, ?> myService = AbstractBaseResourceService.getService(obj.getMyClassType()); if (myService != null) { myService.deleteResource(obj.getId()); } else {/*from w ww . j a v a2 s. c o m*/ logger.error("Service not found for obj=" + obj, new Throwable()); } }