List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getStackTrace
public static String getStackTrace(final Throwable throwable)
Gets the stack trace from a Throwable as a String.
The result of this method vary by JDK version as this method uses Throwable#printStackTrace(java.io.PrintWriter) .
From source file:fredboat.api.API.java
public static void start() { if (!Config.CONFIG.isRestServerEnabled()) { log.warn("Rest server is not enabled. Skipping Spark ignition!"); return;//from w w w. ja v a 2s.c o m } log.info("Igniting Spark API on port: " + PORT); Spark.port(PORT); Spark.before((request, response) -> { log.info(request.requestMethod() + " " + request.pathInfo()); response.header("Access-Control-Allow-Origin", "*"); response.type("application/json"); }); Spark.get("/stats", (req, res) -> { res.type("application/json"); JSONObject root = new JSONObject(); JSONArray a = new JSONArray(); for (FredBoat fb : FredBoat.getShards()) { JSONObject fbStats = new JSONObject(); fbStats.put("id", fb.getShardInfo().getShardId()).put("guilds", fb.getJda().getGuilds().size()) .put("users", fb.getJda().getUsers().size()).put("status", fb.getJda().getStatus()); a.put(fbStats); } JSONObject g = new JSONObject(); g.put("playingPlayers", PlayerRegistry.getPlayingPlayers().size()) .put("totalPlayers", PlayerRegistry.getRegistry().size()) .put("distribution", Config.CONFIG.getDistribution()) .put("guilds", FredBoat.getAllGuilds().size()).put("users", FredBoat.getAllUsersAsMap().size()); root.put("shards", a); root.put("global", g); return root; }); Spark.post("/callback", (request, response) -> { JSONObject out = new JSONObject(); JSONObject body = new JSONObject(request.body()); UConfig uconfig = OAuthManager.handleCallback(body.getString("code")); out.put("bearer", uconfig.getBearer()).put("refresh", uconfig.getRefresh()).put("userId", uconfig.getUserId()); return out; }); /* Exception handling */ Spark.exception(Exception.class, (e, request, response) -> { log.error(request.requestMethod() + " " + request.pathInfo(), e); response.body(ExceptionUtils.getStackTrace(e)); response.type("text/plain"); response.status(500); }); }
From source file:com.aurel.track.plugin.PluginParser.java
private void parse(InputStream is) { //get a factory SAXParserFactory spf = SAXParserFactory.newInstance(); try {/* w ww. j a va 2 s.c o m*/ //get a new instance of parser SAXParser sp = spf.newSAXParser(); //parse the file and also register this class for call backs sp.parse(is, this); } catch (SAXException se) { LOGGER.error(ExceptionUtils.getStackTrace(se)); } catch (ParserConfigurationException pce) { LOGGER.error(ExceptionUtils.getStackTrace(pce)); } catch (IOException ie) { LOGGER.error(ExceptionUtils.getStackTrace(ie)); } }
From source file:com.aurel.track.persist.TAccountPeer.java
/** * Loads a AccountBean by objectID /*from w ww. jav a 2s . c o m*/ * @param objectIDs * @return */ @Override public TAccountBean loadByPrimaryKey(Integer objectID) { TAccount tAccount = null; try { tAccount = retrieveByPK(objectID); } catch (Exception e) { LOGGER.info("Loading the account by primary key " + objectID + " failed with " + e.getMessage()); if (LOGGER.isDebugEnabled()) { LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } if (tAccount != null) { return tAccount.getBean(); } return null; }
From source file:jp.co.ipublishing.aeskit.shelter.ShelterService.java
private void downloadStatuses() { mShelterManager.downloadStatuses().subscribeOn(Schedulers.newThread()) .subscribe(new Subscriber<ShelterStatuses>() { @Override//from w ww .ja va2 s .c o m public void onCompleted() { // Nothing to do } @Override public void onError(Throwable e) { Log.e(TAG, ExceptionUtils.getStackTrace(e)); EventBus.getDefault().post(new ShelterFailedDownloadStatusesEvent(e)); } @Override public void onNext(final ShelterStatuses shelterStatuses) { // ?????? EventBus.getDefault().post(new ShelterUpdatedStatusesEvent(shelterStatuses.getStatuses())); // ????? mShelterManager.updateStatuses(shelterStatuses.getStatuses()) .subscribe(new Subscriber<Void>() { @Override public void onCompleted() { // Nothing to do } @Override public void onError(Throwable e) { Log.e(TAG, ExceptionUtils.getStackTrace(e)); EventBus.getDefault().post(new ShelterFailedUpdateStatusesEvent(e)); } @Override public void onNext(Void aVoid) { // Nothing to do } }); } }); }
From source file:ke.co.tawi.babblesms.server.persistence.accounts.StatusDAO.java
/** * @see ke.co.tawi.babblesms.server.persistence.accounts.BabbleStatusDAO#getStatus(java.lang.String) *///from w w w . java 2 s . c o m @Override public Status getStatus(String uuid) { Status status = null; try (Connection conn = dbCredentials.getConnection(); PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM Status WHERE Uuid = ?;");) { pstmt.setString(1, uuid); ResultSet rset = pstmt.executeQuery(); if (rset.next()) { status = beanProcessor.toBean(rset, Status.class); } rset.close(); } catch (SQLException e) { logger.error("SQLException when getting Status with uuid: " + uuid); logger.error(ExceptionUtils.getStackTrace(e)); } return status; }
From source file:com.aurel.track.master.ModuleBL.java
public static Cookie sendPOSTRequest(String urlString) { Cookie responseCookie = null;//from w w w . j a v a 2 s . c o m try { HttpClient httpclient = new DefaultHttpClient();//HttpClients.createDefault(); HttpPost httppost = new HttpPost(urlString); // Request parameters and other properties. //Execute and get the response. HttpContext localContext = new BasicHttpContext(); CookieStore cookieStore = new BasicCookieStore(); localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore); HttpResponse response = httpclient.execute(httppost, localContext); if (cookieStore.getCookies().size() > 0) { List<org.apache.http.cookie.Cookie> cookies = cookieStore.getCookies(); for (org.apache.http.cookie.Cookie cookie : cookies) { if (cookie.getName().equals("JSESSIONID")) { responseCookie = new Cookie(cookie.getName(), cookie.getValue()); responseCookie.setPath(cookie.getPath()); responseCookie.setDomain(cookie.getDomain()); } } } if (response.getEntity() != null) { response.getEntity().consumeContent(); } } catch (Exception ex) { LOGGER.debug(ExceptionUtils.getStackTrace(ex)); } return responseCookie; }
From source file:me.leorblx.betasrv.utils.Log.java
public void log(Throwable ex) { synchronized (listeners) { for (LogListener listener : listeners) { listener.onError(this, ex); }// ww w . ja v a 2s .c om } log(Level.FATAL, "Encountered an exception:"); log(Level.FATAL, ExceptionUtils.getStackTrace(ex)); }
From source file:me.dinosparkour.commands.Command.java
@Override public void onMessageReceived(MessageReceivedEvent e) { // Checks related to the Event's objects, to prevent concurrency issues. if (e.getAuthor() == null || e.getChannel() == null) return;/*from ww w . j a v a 2 s. c o m*/ if (e.getAuthor().isBot() || !isValidCommand(e.getMessage())) return; // Ignore message if it's not a command or sent by a bot if (authorExclusive() && !e.getAuthor().getId().equals(Info.AUTHOR_ID)) return; // Ignore if the command is meant to be used by the owner only if (e.isFromType(ChannelType.TEXT) && MessageUtil.canNotTalk(e.getTextChannel())) return; // Ignore if we cannot talk in the channel anyway String[] args = commandArgs(e.getMessage()); MessageSender chat = new MessageSender(e); if (e.isFromType(ChannelType.PRIVATE) && !allowsPrivate()) { // Check if the command is guild-only chat.sendMessage("**This command can only be used in a guild!**"); } else { try { executeCommand(args, e, chat); } catch (Exception ex) { ex.printStackTrace(); String msg = "User: **" + MessageUtil.userDiscrimSet(e.getAuthor()) + "**\nMessage:\n*" + MessageUtil.stripFormatting(e.getMessage().getContent()) + "*\n\nStackTrace:```java\n" + ExceptionUtils.getStackTrace(ex) + "```"; if (msg.length() <= 2000) { chat.sendPrivateMessageToUser(msg, e.getJDA().getUserById(Info.AUTHOR_ID)); } } } }
From source file:com.aurel.track.util.ImageServerAction.java
/** * Write the image in the format given to the output stream */// w w w . j a v a 2s .c om @Override public String execute() { System.out.println("IMAGE ACTION !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); ImageProvider imageProvider = (ImageProvider) session.get(imageProviderKey); if (imageProvider == null) { LOGGER.error("Image provider is Null for: " + imageProviderKey); return null; } Map configParametersMap = (Map) session.get(imageProviderParams); LOGGER.debug("imageProviderParams Name :" + imageProviderParams); LOGGER.debug("imageProviderParams Value :" + configParametersMap); if (imageFormat == null || imageFormat.length() < 1) { imageFormat = "png"; } HttpServletResponse response = ServletActionContext.getResponse(); response.setContentType("image/" + imageFormat); try { ServletOutputStream out = response.getOutputStream(); imageProvider.writeImage(out, configParametersMap, imageFormat); } catch (IOException e) { LOGGER.error("Error on write Image:" + e.getMessage()); if (LOGGER.isDebugEnabled()) { LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } return null; }
From source file:com.aurel.track.configExchange.importer.EntityImporter.java
public List<ImportResult> importFile(File uploadFile, ImportContext importContext) throws EntityImporterException { try {/*from w ww .ja va 2 s. co m*/ InputStream is = new FileInputStream(uploadFile); return importFile(is, importContext); } catch (FileNotFoundException e) { LOGGER.warn(ExceptionUtils.getStackTrace(e)); //To change body of catch statement use File | Settings | File Templates. } return new ArrayList<ImportResult>(); }