diff --git a/core/src/main/java/lucee/runtime/tag/Throw.java b/core/src/main/java/lucee/runtime/tag/Throw.java
index b57dc06ab8..545e179d59 100755
--- a/core/src/main/java/lucee/runtime/tag/Throw.java
+++ b/core/src/main/java/lucee/runtime/tag/Throw.java
@@ -59,6 +59,7 @@ public final class Throw extends TagImpl {
private String errorcode = "";
private Object object;
+ private PageException cause;
private int level = 1;
@@ -72,6 +73,7 @@ public void release() {
errorcode = "";
object = null;
level = 1;
+ cause = null;
}
/**
@@ -118,6 +120,14 @@ public void setMessage(String message) {
this.message = message;
}
+ public void setCause(Object cause) throws PageException {
+ if (cause == null) return;
+ if (cause instanceof ThreadDeath) throw new ApplicationException("cannot set this kind [" + cause.getClass().getName() + "] of exception as caused by");
+ this.cause = toPageException(cause, null);
+ if (this.cause == null) throw new ApplicationException("cannot cast this type [" + cause.getClass().getName() + "] to an exception");
+
+ }
+
/**
* set the value errorcode A custom error code that you supply.
*
@@ -201,7 +211,9 @@ public int doStartTag() throws PageException {
_doStartTag(message);
_doStartTag(object);
- throw new CustomTypeException("", detail, errorcode, type, extendedinfo, level);
+ CustomTypeException exception = new CustomTypeException("", detail, errorcode, type, extendedinfo, level);
+ if (cause != null) exception.initCause(cause);
+ throw exception;
}
private void _doStartTag(Object obj) throws PageException {
@@ -210,6 +222,7 @@ private void _doStartTag(Object obj) throws PageException {
if (pe != null) throw pe;
CustomTypeException exception = new CustomTypeException(Caster.toString(obj), detail, errorcode, type, extendedinfo, level);
+ if (cause != null) exception.initCause(cause);
throw exception;
}
}
diff --git a/core/src/main/java/resource/tld/core-base.tld b/core/src/main/java/resource/tld/core-base.tld
index 8655de8903..0ed373cf95 100755
--- a/core/src/main/java/resource/tld/core-base.tld
+++ b/core/src/main/java/resource/tld/core-base.tld
@@ -8021,6 +8021,13 @@ If you terminate a thread, the thread scope includes an ERROR metadata structure
true
a native java exception Object, if this attribute is defined all other will be ignored
+
+ any
+ cause
+ false
+ true
+ the cause of the exception created with this tag. This can be a cfcatch block or a native java exception.
+
numeric
contextLevel
diff --git a/loader/build.xml b/loader/build.xml
index 3ec568cf73..9d58a84a93 100644
--- a/loader/build.xml
+++ b/loader/build.xml
@@ -2,11 +2,11 @@
-
+
-
+
diff --git a/loader/pom.xml b/loader/pom.xml
index 5235dc3635..96e216467d 100644
--- a/loader/pom.xml
+++ b/loader/pom.xml
@@ -3,7 +3,7 @@
org.lucee
lucee
- 6.0.0.533-SNAPSHOT
+ 6.0.0.534-SNAPSHOT
jar
Lucee Loader Build