coldfusion - Throwing error from cfc - cflocation doesn't work from inside onerror() -
coldfusion - Throwing error from cfc - cflocation doesn't work from inside onerror() -
edit: of import piece might i'm calling chlorofluorocarbon method via ajax...
i'm calling chlorofluorocarbon method via ajax, returns info utilize in jqgrid table. within cfc's method, i'm trying set error handling, instead of failing , giving user no indication of problems, send users error page, defined error.cfm in root directory, , right includes boilerplate html. within application.cfc, i've defined onerror() method so:
<cffunction name="onerror" returntype="void" output="false" > <cfargument name="exception" required="true" > <cfargument name="eventname" type="string" required="true" > <cfmail to="#application.registration_notification#" from="outgoing address" subject="error"> </cfmail> <cflocation url="../index.cfm?file=error.cfm" addtoken="false" />
when throw error cfc's method, whether within cfcatch or not, chrome reports have indeed been sent index.cfm status=200, , response shows, correctly, html within error.cfm template. however, browser not go page.
the thing is, if alter location
<cflocation url="index.cfm?file=error.cfm" addtoken="false" />
and throw error page calling cfc, instead of cfc, cflocation work expected. also, if utilize cfinvoke phone call chlorofluorocarbon original page, instead of using ajax call, cflocation works. must have fact i'm making phone call chlorofluorocarbon through ajax, instead of invoking within cf. missing here?
p.s. happens in chrome, ie, , ff. i'm using cf 9.0.1 hotfixes, no frameworks. here's subset of output chrome's network pane, in headers, referring page:
request url:http://localhost/sitename/cfc/method.cfc
request method:get
status code:302 moved temporarily
request headers view source
accept:application/json, text/javascript, /; q=0.01
accept-charset:iso-8859-1,utf-8;q=0.7,*;q=0.3
accept-encoding:gzip,deflate,sdch
accept-language:en-us,en;q=0.8
connection:keep-alive
cookie:cfid=11801; cftoken=90037336; lastvisit=1327852981759
host:localhost
referer:http://localhost/sitename/index.cfm?file=referringfile.cfm
user-agent:mozilla/5.0 (windows nt 6.1; wow64) applewebkit/535.7 (khtml, gecko) chrome/16.0.912.77 safari/535.7
x-requested-with:xmlhttprequest
query string parameters view url encoded
method:getpartnumbers
filter:{"page":1,"sessionsql":"1327834969791","filterrows":[{"field_name":"part_number","operand":"equals","field_value":"11 06 01"}]}
_search:false
nd:1327835014639
rows:100
page:1
sidx:part_number
sord:desc
response headers view source
content-type:text/html; charset=utf-8
date:sun, 29 jan 2012 11:03:34 gmt
location:../index.cfm?file=error.cfm
persistent-auth:true
server:microsoft-iis/7.5
set-cookie:lastvisit=1327853014657;expires=fri, 27-jul-2012 11:03:34 gmt;path=/
transfer-encoding:chunked
x-powered-by:asp.net
and error.cfm page:
request url:http://localhost/sitename/index.cfm?file=error.cfm
request method:get
status code:200 ok
request headers view source
accept:application/json, text/javascript, /; q=0.01
accept-charset:iso-8859-1,utf-8;q=0.7,*;q=0.3
accept-encoding:gzip,deflate,sdch
accept-language:en-us,en;q=0.8
authorization:negotiate blahblahblahblah
connection:keep-alive
cookie:cfid=11801; cftoken=90037336; lastvisit=1327716554490
host:localhost
referer:http://localhost/sitename/index.cfm?file=filename/filename.cfm&config=filename
user-agent:mozilla/5.0 (windows nt 6.1; wow64) applewebkit/535.7 (khtml, gecko) chrome/16.0.912.77 safari/535.7
x-requested-with:xmlhttprequest
query string parameters view url encoded
file:error.cfm
response headers view source
content-type:text/html; charset=utf-8 date:fri, 27 jan 2012 21:09:14
gmt persistent-auth:true server:microsoft-iis/7.5
set-cookie:lastvisit=1327716554533;expires=wed, 25-jul-2012 21:09:14 gmt;path=/
transfer-encoding:chunked
x-powered-by:asp.net
edit: sorry, misread question...
updated: seek including template handle cflocation, doing cflocation within application.cfc might disallowed since happening before request fired?
application.cfc
component { this.name = 'errortest'; public void function onerror(required exception, required string eventname) { include 'errorredirect.cfm'; } }
index.cfm (has error in code demo)
<cfscript> = form.nonexistentvariable; </cfscript>
errorredirect.cfm
<cflocation url="error.html">
error.html
<h1>sorry, error has occurred. </h1>
test.cfc (test test.cfc?method=test demo chlorofluorocarbon based error)
component { remote function test () { = form.doesnotexist; } }
coldfusion cfc onerror
Comments
Post a Comment