Ticket #320 (closed enhancement: fixed)
When the framework attempts to load a helper file with a bug in it, the error message is misleading
| Reported by: | DanWilson | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Version: | 3.0.178 | Severity: | major |
| Keywords: | Cc: |
Description
Originally posted by Dan Wilson on 5/14/2008 at 8:40 AM: entered by Ezra Parker on port to new system
The error thrown when a helper file can not be loaded indicates the file does not exist. In the case of a helper file with errors in it, the error message is misleading...
I recommend catching the filenotfound message separately and throwing a different error: e.g.
<cffunction name="injectPath" output="false" hint="Injects files (.cfm or .cfc) from a path into a target cfc. Not recursive.">
<cfargument name="target" />
<cfargument name="path" />
<cfset var files = "" />
<cfdirectory action="list" directory="#expandPath(arguments.path)#" name="files">
<cfloop query="files">
<cftry>
<cfif listLast(files.name, ".") eq "cfc">
<cfset injectComponent(arguments.target, arguments.path & "/" & files.name) />
<cfelseif listLast(files.name, ".") eq "cfm">
<cfset injectInclude(arguments.target, arguments.path & "/" & files.name) />
<cfelse>
<cfdump var="#arguments#">
</cfif>
<cfcatch type="coldfusion.runtime.TemplateNotFoundException">
<cfthrow message="Couldn't add helper: #arguments.path#/#files.name#. Have you tested it and made sure the file exists? " />
</cfcatch>
<cfcatch>
<cfthrow message="Couldn't add helper: #arguments.path#/#files.name#. There is probably a bug in the file. I'm sorry it didn't work out." />
</cfcatch>
</cftry>
</cfloop>
</cffunction>
Change History
Note: See
TracTickets for help on using
tickets.
![(please configure the [header_logo] section in trac.ini)](/ModelGlue.com/trac.cgi/chrome/site/your_project_logo.png)