Skip to content

Commit

Permalink
improve the throw function (add cause)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Sep 4, 2023
1 parent 8f174e8 commit 54ccf0e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
29 changes: 17 additions & 12 deletions core/src/main/java/resource/library/function/throw.cfm
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<cffunction name="throw" output="no" returntype="void"
hint="Throws a developer-specified exception, which can be caught with a cfcatch tag"><cfargument
name="message" type="string" required="no" hint="Message that describes exception event."><cfargument
name="type" type="string" required="no" default="application" hint="- 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."><cfargument
name="detail" type="string" required="no" hint="additional detailed description of the exception."><cfargument
name="errorcode" type="string" required="no" hint=" A custom error code that you supply."><cfargument
name="extendedInfo" type="string" required="no" hint="extended information to the exception."><cfargument
name="object" type="any" required="no" hint="Throws a Java exception from a CFML tag. This attribute is mutually exclusive with all other arguments of this function."><!---
---><cfthrow attributeCollection="#arguments#" contextlevel="2"><!---
---></cffunction>
<cfscript>
/**
* 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) {
```<cfthrow attributeCollection="#arguments#" contextlevel="2">```
}
</cfscript>
4 changes: 2 additions & 2 deletions test/tickets/LDEV4635.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 ) {
Expand Down

0 comments on commit 54ccf0e

Please sign in to comment.