Ticket #320 (closed enhancement: fixed)

Opened 17 years ago

Last modified 17 years ago

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

Changed 17 years ago by cfgrok

  • status changed from new to closed
  • resolution set to fixed

Originally posted by Dan Wilson on 6/27/2008 at 7:05 PM: entered by Ezra Parker on port to new system

This has been committed

Note: See TracTickets for help on using tickets.