From 54ccf0e9de67d9840a15af70b316e011fa5dcb04 Mon Sep 17 00:00:00 2001 From: michaeloffner Date: Mon, 4 Sep 2023 16:49:22 +0200 Subject: [PATCH] improve the throw function (add cause) --- .../java/resource/library/function/throw.cfm | 29 +++++++++++-------- test/tickets/LDEV4635.cfc | 4 +-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/resource/library/function/throw.cfm b/core/src/main/java/resource/library/function/throw.cfm index d0c8414ffa..091b5012e8 100755 --- a/core/src/main/java/resource/library/function/throw.cfm +++ b/core/src/main/java/resource/library/function/throw.cfm @@ -1,12 +1,17 @@ - \ No newline at end of file + + /** + * Throws a developer-specified exception, which can be caught with a cfcatch tag + * @message Message that describes exception event. + * @type - A custom type + * - Application + * Do not enter another predefined type; types are not generated by CFML applications. If you specify Application, you need not specify a type for cfcatch. + * @detail additional detailed description of the exception. + * @errorcode A custom error code that you supply. + * @extendedInfo extended information to the exception. + * @object Throws a Java exception from a CFML tag. This attribute is mutually exclusive with all other arguments of this function. + * @cause The cause of the exception created with this tag. This can be a cfcatch block or a native java exception. + */ + void function throw(string message, string type="application", string detail, string errorcode, string extendedInfo, object, cause) { + `````` + } + \ No newline at end of file diff --git a/test/tickets/LDEV4635.cfc b/test/tickets/LDEV4635.cfc index cfa4f3e94b..da758accbb 100644 --- a/test/tickets/LDEV4635.cfc +++ b/test/tickets/LDEV4635.cfc @@ -40,7 +40,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="s3" { try { directory action="copy" directory="#srcDir#" destination="#arguments.bucket#" storelocation="#arguments.storelocation#"; } catch (e){ - throw REReplaceNoCase(e.stacktrace,"[***]", "all"); + throw(message:REReplaceNoCase(e.stacktrace,"[***]", "all"), cause:e); } expect( directoryExists( arguments.bucket ) ).toBeTrue(); if ( checkS3Version() neq 0 ) { @@ -56,7 +56,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="s3" { try { directory action="rename" directory="#arguments.bucket#" newDirectory="#renameBucket#" storelocation="#arguments.renameLocation#"; } catch (e){ - throw REReplaceNoCase(e.stacktrace,"[***]", "all"); + throw(message:REReplaceNoCase(e.stacktrace,"[***]", "all"), cause:e); } expect( directoryExists( renameBucket ) ).toBeTrue(); if ( checkS3Version() neq 0 ) {