James A Mohler
James A Mohler

Reputation: 11120

Per subsystem error files in FW/1

I am trying to get per subsystem error files in FW/1. I know the following does not work.

variables.framework = {
...

error = getSubsystem() .error', 
...

UPDATE

I tried

<cffunction name="onError">
<cfargument name="Exception" type="Struct" required />
<cfargument name="Event"     type="String" required />

<cfif Arguments.Exception.Type EQ 'missinginclude' >
    <cfoutput>#layout('#getSubsystem()#:default',view('login/error'))#</cfoutput>
    <cfreturn false />
</cfif>

<cfreturn super.onError(ArgumentCollection=Arguments) />
</cffunction>

And I get an error of:

The EXCEPTION argument passed to the onError function is not of type Struct.

If the component name is specified as a type of this argument, it is possible that either a definition file for the component cannot be found or is not accessible.

The error occurred in /Applications/ColdFusion10/cfusion/wwwroot/Pluma/Application.cfc: line 189
 187 : </cffunction>    
 188 :  
 189 : <cffunction name="onError">
 190 :     <cfargument name="Exception" type="Struct" required />
 191 :     <cfargument name="Event"     type="String" required />

Upvotes: 0

Views: 400

Answers (1)

Peter Boughton
Peter Boughton

Reputation: 112150

What you can do is override the onError method in your Application.cfc to manually call the relevant per-subsystem files.

Here's an example of handling missinginclude errors with a layout in a non-default subsystem:

<cffunction name="onError">
    <cfargument name="Exception" type="Struct" required />
    <cfargument name="Event"     type="String" required />

    <cfif Arguments.Exception.Type EQ 'missinginclude' >
        <cfoutput>#layout('subsys2:default',view('main:errors/404'))#</cfoutput>
        <cfreturn false />
    </cfif>

    <cfreturn super.onError(ArgumentCollection=Arguments) />
</cffunction>

Returning super.onError will result in the standard error handling being invoked.

For making it completely per-subsystem you could do something like view(getSubsystem()&':errors') or similar.

If you're doing potentially complex logic, remember to use appropriate try/catch - tracking errors in your error handling can be awkward.

Upvotes: 1

Related Questions