use of lucee.runtime.exp.CustomTypeException in project Lucee by lucee.
the class Throw method _doStartTag.
private void _doStartTag(Object obj) throws PageException {
if (!StringUtil.isEmpty(obj)) {
PageException pe = toPageException(obj, null);
if (pe != null)
throw pe;
CustomTypeException exception = new CustomTypeException(Caster.toString(obj), detail, errorcode, type, extendedinfo, level);
throw exception;
}
}
use of lucee.runtime.exp.CustomTypeException in project Lucee by lucee.
the class Throw method toPageException.
public static PageException toPageException(Object object, PageException defaultValue) throws PageException {
if ((object instanceof ObjectWrap))
return toPageException(((ObjectWrap) object).getEmbededObject(), defaultValue);
if (object instanceof CatchBlock) {
CatchBlock cb = (CatchBlock) object;
return cb.getPageException();
}
if (object instanceof PageException)
return (PageException) object;
if (object instanceof Throwable) {
Throwable t = (Throwable) object;
return new CustomTypeException(t.getMessage(), "", "", t.getClass().getName(), "");
}
if (object instanceof Struct) {
Struct sct = (Struct) object;
String type = Caster.toString(sct.get(KeyConstants._type, ""), "").trim();
String msg = Caster.toString(sct.get(KeyConstants._message, null), null);
if (!StringUtil.isEmpty(msg, true)) {
String detail = Caster.toString(sct.get(KeyConstants._detail, null), null);
String errCode = Caster.toString(sct.get("ErrorCode", null), null);
String extInfo = Caster.toString(sct.get("ExtendedInfo", null), null);
PageException pe = null;
if ("application".equalsIgnoreCase(type))
pe = new ApplicationException(msg, detail);
else if ("expression".equalsIgnoreCase(type))
pe = new ExpressionException(msg, detail);
else
pe = new CustomTypeException(msg, detail, errCode, type, extInfo);
// Extended Info
if (!StringUtil.isEmpty(extInfo, true))
pe.setExtendedInfo(extInfo);
// Error Code
if (!StringUtil.isEmpty(errCode, true))
pe.setErrorCode(errCode);
// Additional
if (pe instanceof PageExceptionImpl) {
PageExceptionImpl pei = (PageExceptionImpl) pe;
sct = Caster.toStruct(sct.get("additional", null), null);
if (sct != null) {
Iterator<Entry<Key, Object>> it = sct.entryIterator();
Entry<Key, Object> e;
while (it.hasNext()) {
e = it.next();
pei.setAdditional(e.getKey(), e.getValue());
}
}
}
return pe;
}
}
return defaultValue;
}
Aggregations