Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 92406

Re: Disable cffunction accepting undeclared arguments?

$
0
0

I think I get it now. The argument name is status_code, but what gets into the function is arguments.status instead of arguments.status_code. Right?

 

If so, you should check where the function is called with the argument status_code. There might be a space between status and _code. In any case, at the point where the function is called, retype the name status_code, just to be sure.

 

Bradleythall wrote:

 

I would like coldfusion to throw an error any time there is something in the arguments scope that is not an expected argument.

Use code similar to that in bold.

 

<cffunction name="testFunc">

<cfargument name="arg">

<cfargument name="myArg">

<cfargument name="myOtherArg">

<!--- List arguments in alphabetical order to enable comparison --->

<cfif listSort(StructKeyList(arguments),"textnocase","asc") is not "arg,myArg,myOtherArg">

    <cfthrow message="An unexpected argument was passed to the function">

</cfif>

<cfreturn "Success!">

</cffunction>

 

<cfoutput>#testFunc(someOtherArg=1)#</cfoutput>


Viewing all articles
Browse latest Browse all 92406

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>