List of usage examples for org.apache.commons.lang3.exception ContextedException addContextValue
@Override public ContextedException addContextValue(final String label, final Object value)
From source file:com.rodaxsoft.mailgun.MailingListMemberManager.java
/** * Converts the <code>vars</code> object into an instance of the varsType and * returns the members of the mailing list * @param varsType The target type for the <i>vars</i> object. * <i>Note: If no registered {@link Converter} is found for the varsType, * a {@link ContextedRuntimeException} will be thrown.</i> * @return A list of list member objects * @throws ContextedException If no registered {@link Converter} is found for the varsType * @see ConvertUtils#register(Converter, Class) * @since 0.2// w w w.ja v a 2 s . c o m * */ List<ListMember> getListMembers(Class<?> varsType) throws ContextedException { List<ListMember> members = null; if (varsType != null) { if (ConvertUtils.lookup(varsType) != null) { listMemberConverter.setVarClass(varsType); } else { ContextedException cre; cre = new ContextedException("No registered Converter for varType"); cre.addContextValue("varType", varsType.getName()); throw cre; } } final String path = "/lists/" + listAddress + "/members"; RESTResponse response = invokeGet(path); if (response.success()) { JSONObject jsonObj = response.toJSONObject(); JSONArray jsonArray = jsonObj.getJSONArray("items"); @SuppressWarnings("unchecked") Iterator<JSONObject> iter = jsonArray.iterator(); while (iter.hasNext()) { JSONObject obj = iter.next(); if (null == members) { members = new ArrayList<>(); } ListMember lm = (ListMember) ConvertUtils.convert(obj, ListMember.class); members.add(lm); } } return members; }