Refine search
public void onMRTaskComplete (boolean isSuccess, Throwable t) throws RuntimeException { if (isSuccess) { this.workingState = WorkUnitState.WorkingState.SUCCESSFUL; } else if (t == null) { this.workingState = WorkUnitState.WorkingState.FAILED; } else { log.error ("Failed to run MR job with exception {}", ExceptionUtils.getStackTrace(t)); this.workingState = WorkUnitState.WorkingState.FAILED; } }
public static void sleepSec(int sec) { try { TimeUnit.SECONDS.sleep(sec); } catch (InterruptedException e) { log.warn("Caught exception: " + ExceptionUtils.getFullStackTrace(e)); } } public static void sleepMilliSec(int milliSec) {
/** * Gets a short message summarising the root cause exception. * <p> * The message returned is of the form * {ClassNameWithoutPackage}: {ThrowableMessage} * * @param th the throwable to get a message for, null returns empty string * @return the message, non-null * @since Commons Lang 2.2 */ public static String getRootCauseMessage(Throwable th) { Throwable root = ExceptionUtils.getRootCause(th); root = (root == null ? th : root); return getMessage(root); }
private String getJobExceptionStack(Throwable e) { if (e == null) { return ""; } Throwable cause = ExceptionUtils.getRootCause(e); if (cause != null) { return ExceptionUtils.getFullStackTrace(cause); } else { return ExceptionUtils.getFullStackTrace(e); } }
/** * <p>Captures the stack trace associated with the specified * <code>Throwable</code> object, decomposing it into a list of * stack frames.</p> * * <p>The result of this method vary by JDK version as this method * uses {@link Throwable#printStackTrace(java.io.PrintWriter)}. * On JDK1.3 and earlier, the cause exception will not be shown * unless the specified throwable alters printStackTrace.</p> * * @param throwable the <code>Throwable</code> to examine, may be null * @return an array of strings describing each stack frame, never null */ public static String[] getStackFrames(Throwable throwable) { if (throwable == null) { return ArrayUtils.EMPTY_STRING_ARRAY; } return getStackFrames(getStackTrace(throwable)); }
@GET @Path("/users/{UID}/views") @ApiOperation(value="Get a list of available views", response=BodyTrackHelper.ViewsList.class) @Produces({MediaType.APPLICATION_JSON}) @ApiResponses({ @ApiResponse(code=403, message="In case of unauthorized access") }) public Response getViews(@ApiParam(value="User ID", required=true) @PathParam("UID") Long uid) { try{ long loggedInUserId = AuthHelper.getGuestId(); boolean accessAllowed = isOwnerOrAdmin(uid); TrustedBuddy trustedBuddy = buddiesService.getTrustedBuddy(loggedInUserId, uid); if (!accessAllowed&& trustedBuddy ==null){ uid = null; } return Response.ok(bodyTrackHelper.listViews(uid)).build(); } catch (Exception e){ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ExceptionUtils.getStackTrace(e)).build(); } }
@POST @Secured({ "ROLE_ADMIN" }) @Path("/cleanup") @Produces({ MediaType.APPLICATION_JSON }) public Response deleteStaleData() throws InstantiationException, IllegalAccessException, ClassNotFoundException { StringBuffer sb = new StringBuffer("Cleaning up stale data..."); long then = System.currentTimeMillis(); try { apiDataCleanupService.cleanupStaleData(); } catch (Exception e) { StringBuffer sb1 = sb.append("Couldn't cleanup api staled data") .append(" message=\"" + e.getMessage() + "\"\n" + org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)); sb.append("\n").append(sb1); FlxLogger.getLogger("org.fluxtream.core.updaters.quartz").warn(sb1.toString()); } try { connectorUpdateService.cleanupStaleData(); } catch (Exception e) { StringBuilder sb2 = new StringBuilder("Couldn't cleanup old update data") .append(" message=\"" + e.getMessage() + "\"\n" + org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(e)); sb.append("\n").append(sb2); FlxLogger.getLogger("org.fluxtream.core.updaters.quartz").warn(sb2.toString()); } sb.append("Done (" + (System.currentTimeMillis()-then) + " ms)"); return Response.ok().entity(sb.toString()).build(); }
@POST @RequiresPermissions(permissions = PERMISSION_CREATE) @Produces(MimeTypes.APPLICATION_JSON_UTF8) @Consumes(MimeTypes.APPLICATION_JSON_UTF8) public Response httpPostJson(String jsonObject) throws Exception { commitTransaction(); } catch (Throwable e) { String rootCauseMessage = ExceptionUtils.getRootCauseMessage(e); logger.warn(rootCauseMessage, e); return Response.serverError().entity(e).build();
@GET @Path("/instancetyperecords/daily/{date}") public Response getInstanceTypeRecordsDaily(@PathParam("date") @NotNull String dateStr) { logger.error(ExceptionUtils.getRootCauseMessage(e)); logger.error(ExceptionUtils.getFullStackTrace(e));
@PUT @Path("{databaseName}") @Produces(MediaType.APPLICATION_JSON) public Response saveConnection(@PathParam("databaseName") String databaseName) { ConnectionProvider connectionProvider = persistence.getConnectionProvider(databaseName); ConnectionProviderDetail cp = new ConnectionProviderDetail(connectionProvider); Form form = new FormBuilder(ConnectionProviderDetail.class).build(); form.readFromObject(cp); form.readFromRequest(context.getRequest()); //TODO schema select if(form.validate()) { form.writeToObject(cp); try { connectionProvider.init(persistence.getDatabasePlatformsRegistry()); persistence.initModel(); persistence.saveXmlModel(); return Response.ok(form).build(); } catch (Exception e) { String msg = "Cannot save model: " + ExceptionUtils.getRootCauseMessage(e); logger.error(msg, e); RequestMessages.addErrorMessage(msg); return Response.serverError().entity(form).build(); } } return Response.serverError().entity(form).build(); }
@POST @Path("/users/{UID}/channels/{DeviceNickname}.{ChannelName}/set") @ApiOperation(value = "Set the default style for a channel") @ApiResponses({ @ApiResponse(code=200, message="Channel style set"), @ApiResponse(code=403, message="In case of unauthorized access") }) public Response setDefaultStyle(@ApiParam(value="User ID", required = true) @PathParam("UID") Long uid, @ApiParam(value="Device name", required = true) @PathParam("DeviceNickname") String deviceNickname, @ApiParam(value="Channel name", required = true) @PathParam("ChannelName") String channelName, @ApiParam(value="Style data", required = true) @FormParam("user_default_style") String style) { try{ if (!isOwnerOrAdmin(uid)){ uid = null; } bodyTrackHelper.setDefaultStyle(uid,deviceNickname,channelName,style); return Response.ok("Channel style set").build(); } catch (Exception e){ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ExceptionUtils.getStackTrace(e)).build(); } }
@Produces(MimeTypes.APPLICATION_JSON_UTF8) @Consumes(MimeTypes.APPLICATION_JSON_UTF8) public Response httpPutJson(String jsonObject) throws Exception { commitTransaction(); } catch (Throwable e) { String rootCauseMessage = ExceptionUtils.getRootCauseMessage(e); logger.warn(rootCauseMessage, e); return Response.serverError().entity(e).build();
LOG.error("Orphan View Tool : An exception occurred " + ExceptionUtils.getMessage(ex) + " at:\n" + ExceptionUtils.getStackTrace(ex)); return -1; } finally {
private static Throwable getRootCause(Throwable t) { Throwable rootCause = ExceptionUtils.getRootCause(t); if (rootCause == null) { rootCause = t; } return rootCause; } }
private TableMeta getTableMeta(String dbName, String tbName, boolean useCache, EntryPosition position) { try { return tableMetaCache.getTableMeta(dbName, tbName, useCache, position); } catch (Throwable e) { String message = ExceptionUtils.getRootCauseMessage(e); if (filterTableError) { if (StringUtils.contains(message, "errorNumber=1146") && StringUtils.contains(message, "doesn't exist")) { return null; } else if (StringUtils.contains(message, "errorNumber=1142") && StringUtils.contains(message, "command denied")) { return null; } } throw new CanalParseException(e); } }
public static Response responseException(Exception e, Logger logger, OperationStats opStats, Map<String, String> tags) { logger.error(ExceptionUtils.getFullStackTrace(e)); logger.error(ExceptionUtils.getRootCauseMessage(e)); tags.put("status", String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())); tags.put("message", e.getClass().getSimpleName()); opStats.failed(tags); return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .type(MediaType.APPLICATION_JSON) .build(); } }
public CompileError(INamespace namespace, Throwable throwable, int line) { super(namespace, ExceptionUtils.getMessage(throwable), line); this.cause = throwable; }
@GET @Path(value = "/users/{UID}/tags") @ApiOperation(value = "Retrieve all tags for a user", response=Tag.class, responseContainer="Array") @ApiResponses({ @ApiResponse(code=403, message="In case of unauthorized access") }) @Produces({MediaType.APPLICATION_JSON}) public Response getAllTagsForUser(@ApiParam(value="User ID", required = true) @PathParam("UID") Long uid) { try { long loggedInUserId = AuthHelper.getGuestId(); boolean accessAllowed = isOwnerOrAdmin(uid); TrustedBuddy trustedBuddy = buddiesService.getTrustedBuddy(loggedInUserId, uid); if (!accessAllowed && trustedBuddy == null) { uid = null; } return Response.ok(bodyTrackHelper.getAllTagsForUser(uid)).build(); } catch (Exception e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ExceptionUtils.getStackTrace(e)).build(); } }
@POST @Path("/users/{UID}/views") @ApiOperation(value="Create a new view with given name and data", response = BodyTrackHelper.AddViewResult.class) @ApiResponses({ @ApiResponse(code=403, message="In case of unauthorized access") }) @Produces({MediaType.APPLICATION_JSON}) public Response setView(@ApiParam(value="User ID", required = true) @PathParam("UID") Long uid, @ApiParam(value="View name", required = true) @FormParam("name") String name, @ApiParam(value="View data", required = true) @FormParam("data") String data) { try{ long loggedInUserId = AuthHelper.getGuestId(); boolean accessAllowed = isOwnerOrAdmin(uid); TrustedBuddy trustedBuddy = buddiesService.getTrustedBuddy(loggedInUserId, uid); if (!accessAllowed && trustedBuddy ==null) { uid = null; } return Response.ok(bodyTrackHelper.saveView(uid, name, data)).build(); } catch (Exception e){ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ExceptionUtils.getStackTrace(e)).build(); } }
@POST @RequiresPermissions(permissions = PERMISSION_CREATE) @Produces(MimeTypes.APPLICATION_JSON_UTF8) @Consumes(MimeTypes.APPLICATION_JSON_UTF8) public Response httpPostJson(String jsonObject) throws Exception { commitTransaction(); } catch (Throwable e) { String rootCauseMessage = ExceptionUtils.getRootCauseMessage(e); logger.warn(rootCauseMessage, e); return Response.serverError().entity(e).build();