List of usage examples for java.lang NullPointerException initCause
public synchronized Throwable initCause(Throwable cause)
From source file:Main.java
static void demoproc() { NullPointerException e = new NullPointerException("top layer"); e.initCause(new ArithmeticException("cause")); throw e;//from ww w.j ava 2s.c om }
From source file:ChainExcDemo.java
static void demoproc() { NullPointerException e = new NullPointerException("top layer"); e.initCause(new ArithmeticException("cause")); throw e;//from w w w.ja va 2s .com }
From source file:org.catechis.Stats.java
private void addErrorToLog(java.lang.NullPointerException npe) { log.add("toString : " + npe.toString()); log.add("getMessage : " + npe.getMessage()); log.add("getLocalziedMessage:" + npe.getLocalizedMessage()); Throwable throwup = npe.getCause(); Throwable init_cause = npe.initCause(throwup); log.add("thowable.msg :" + init_cause.toString()); StackTraceElement[] ste = npe.getStackTrace(); for (int j = 0; j < ste.length; j++) { log.add(j + " - " + ste[j].toString()); if (j > 6) { log.add(" ..."); break; }/*from w w w . j ava 2 s . co m*/ } }
From source file:org.intermine.dwr.AjaxServices.java
/** * Summarises the given template query./* w ww .ja v a2 s. c o m*/ * * @param templateName the template query name * @return a String to guarantee the service ran properly */ public String summarise(String templateName) { try { WebContext ctx = WebContextFactory.get(); HttpSession session = ctx.getSession(); final InterMineAPI im = SessionMethods.getInterMineAPI(session); Profile profile = SessionMethods.getProfile(session); Map<String, ApiTemplate> templates = profile.getSavedTemplates(); ApiTemplate template = templates.get(templateName); TemplateSummariser summariser = im.getTemplateSummariser(); try { session.setAttribute("summarising_" + templateName, "true"); summariser.summarise(template); } catch (ObjectStoreException e) { LOG.error("Failed to summarise " + templateName, e); } catch (NullPointerException e) { NullPointerException e2 = new NullPointerException("No such template " + templateName); e2.initCause(e); throw e2; } finally { session.removeAttribute("summarising_" + templateName); } } catch (RuntimeException e) { processException(e); } return "summarised"; }
From source file:org.intermine.pathquery.PathQuery.java
/** * Adds a group of elements to the view list. The elements should be normal path expressions, * with dots separating the parts. Do not use colons to represent outer joins, and do not use * square brackets to represent subclass constraints. The paths will not be verified until the * verifyQuery() method is called, but will merely be checked for format. The paths will be * added in the order of the iterator of the collection. If there is an error with any of the * elements of the collection, then none of the elements will be added and the query will be * unchanged.//w w w . j av a 2s.com * * @param viewPaths a Collection of String paths to add to the view list * @throws NullPointerException if viewPaths is null or contains a null element * @throws IllegalArgumentException if a view path contains colons or square brackets, or is * otherwise in a bad format */ public synchronized void addViews(Collection<String> viewPaths) { deVerify(); try { for (String viewPath : viewPaths) { checkPathFormat(viewPath); } for (String viewPath : viewPaths) { addView(viewPath); } } catch (NullPointerException e) { NullPointerException e2 = new NullPointerException("While adding list to view: " + viewPaths); e2.initCause(e); throw e2; } catch (IllegalArgumentException e) { throw new IllegalArgumentException("While adding list to view: " + viewPaths, e); } }
From source file:org.intermine.pathquery.PathQuery.java
/** * Adds a group of elements to the view list. The elements should be normal path expressions, * with dots separating the parts. Do not use colons to represent outer joins, and do not use * square brackets to represent subclass constraints. The paths will not be verified until the * verifyQuery() method is called, but will merely be checked for format. The paths will be * added in the order of the arguments (varargs or array). If there is an error with any of the * elements of the array/varargs, then none of the elements will be added and the query will be * unchanged.//from w w w . j a v a 2 s . com * * @param viewPaths String paths to add to the view list * @throws NullPointerException if viewPaths is null or contains a null element * @throws IllegalArgumentException if a view path contains colons or square brackets, or is * otherwise in a bad format */ public synchronized void addViews(String... viewPaths) { deVerify(); try { for (String viewPath : viewPaths) { checkPathFormat(viewPath); } for (String viewPath : viewPaths) { addView(viewPath); } } catch (NullPointerException e) { NullPointerException e2 = new NullPointerException("While adding array to view: " + viewPaths); e2.initCause(e); throw e2; } catch (IllegalArgumentException e) { throw new IllegalArgumentException("While adding array to view: " + viewPaths, e); } }
From source file:org.intermine.pathquery.PathQuery.java
/** * Adds a group of elements to the view list, given a space-separated list. The elements should * be normal path expressions, with dots separating the parts. Do not use colons to represent * outer joins, and do not use square brackets to represent subclass constraints. The paths * will not be verified until the verifyQuery() method is called, but will merely be checked * for format. The paths will be added preserving the order in the argument. The paths should be * separated by spaces in the argument, but not commas. If there is an error with any of the * elements in the argument, then none of the elements will be added and the query will be * unchanged.// w w w . j ava 2 s . co m * * @param viewPaths String paths to add to the view list * @throws NullPointerException if viewPaths is null or contains a null element * @throws IllegalArgumentException if a view path contains colons or square brackets, or is * otherwise in a bad format */ public synchronized void addViewSpaceSeparated(String viewPaths) { deVerify(); try { String[] viewPathArray = SPACE_SPLITTER.split(viewPaths.trim()); for (String viewPath : viewPathArray) { if (!"".equals(viewPath)) { checkPathFormat(viewPath); } } for (String viewPath : viewPathArray) { if (!"".equals(viewPath)) { addView(viewPath); } } } catch (NullPointerException e) { NullPointerException e2 = new NullPointerException( "While adding space-separated list " + "to view: \"" + viewPaths + "\""); e2.initCause(e); throw e2; } catch (IllegalArgumentException e) { throw new IllegalArgumentException("While adding space-separated list to view: \"" + viewPaths + "\"", e); } }
From source file:org.intermine.pathquery.PathQuery.java
/** * Adds a group of elements to the order by list, given a space-separated list. The elements * should be normal path expressions, with dots separating the parts. Do not use colons to * represent outer joins, and do not use square brackets to represent subclass constraints. The * paths will not be verified until the verifyQuery() method is called, but will merely be * checked for format. The paths will be added preserving the order in the argument. Each * element should be a path expression followed by a space and then either "asc" or "desc" to * describe the direction of sorting, and the elements should be separated by spaces. If there * is an error with any of the elements in the argument, then none of the elements will be * added and the query will be unchanged. * * @param orderString the order elements in space-separated string form * @throws NullPointerException if orderString is null * @throws IllegalArgumentException if a path expression contains colons or square brackets, or * is otherwise in a bad format, or if there is not an even number of space-separated elements, * or if any even-numbered element is not either "asc" or "desc". *//*from w w w. j av a 2 s . co m*/ public synchronized void addOrderBySpaceSeparated(String orderString) { deVerify(); try { String[] orderPathArray = SPACE_SPLITTER.split(orderString.trim()); if (orderPathArray.length % 2 != 0) { throw new IllegalArgumentException("Order String must contain alternating paths and" + " directions, so must have an even number of space-separated elements."); } List<OrderElement> toAdd = new ArrayList<OrderElement>(); for (int i = 0; i < orderPathArray.length - 1; i += 2) { if ("asc".equals(orderPathArray[i + 1].toLowerCase())) { toAdd.add(new OrderElement(orderPathArray[i], OrderDirection.ASC)); } else if ("desc".equals(orderPathArray[i + 1].toLowerCase())) { toAdd.add(new OrderElement(orderPathArray[i], OrderDirection.DESC)); } else { throw new IllegalArgumentException( "Order direction \"" + orderPathArray[i + 1] + "\" must be either \"asc\" or \"desc\""); } } addOrderBys(toAdd); } catch (NullPointerException e) { NullPointerException e2 = new NullPointerException( "While adding space-separated list " + "to order by: \"" + orderString + "\""); e2.initCause(e); throw e2; } catch (IllegalArgumentException e) { throw new IllegalArgumentException( "While adding space-separated list to order by: \"" + orderString + "\""); } }