473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How can I pass cferror info to a component?

Haitashi
I created a component that sends me an email every time an error occurs on my website.

I did a cftry and if that fails it passes the following params to that component:
Expand|Select|Wrap|Line Numbers
  1. <cfinvokeargument name="oFusebox" value="#myfusebox#" />
  2. <cfinvokeargument name="oClientError" value="#request.oClientError#" />
  3. <cfinvokeargument name="oCfcatch" value="#cfcatch#" />
However, I need to pass also the information inside cferror.
Not entirely sure how to do this.

Any ideas?
Nov 12 '07 #1

✓ answered by Haitashi

I wanted to get an email with information about the error. Like when and where it happened.

We're using the Fusebox framework with our app.

What I did to solve this was that I created a an cferror.cfm template/component. In that template I created an object and called it oErrorDetails. Now, there are two ways that information is going to get passed into that object. One is if an error occurs and another is a using a try/catch.

The component is called Alerts.

When an error occurs I don't have to worry about because it will take care of itself by calling the cferror template(because that's the template specified to handle errors). But I can also use that component with my try/catch. For example:

Expand|Select|Wrap|Line Numbers
  1. <cftry>
  2.         <cfset Variables.temp = Variables.oStaffMember.load(Variables.nAdTeacherID) />
  3.     <cfcatch type="API.LXD.Validation">
  4.         <cfset Variables.temp = Request.oClientError.setError("noStaffMember", "A Staff Member ID has not been loaded.") />
  5.  
  6.         <cfinvoke component="cfc.utility.facade.Alert" method="send" returnvariable="success">
  7.             <cfinvokeargument name="oFusebox" value="#myfusebox#" />
  8.             <cfinvokeargument name="oClientError" value="#request.oClientError#" />
  9.             <cfinvokeargument name="oErrorDetail" value="#cfcatch#" />
  10.         </cfinvoke>
  11.     </cfcatch>
  12. </cftry>
I passed the information contained in "cfcatch" to the component using cfinvokeargument.

It's great because the component emails me information about the error like:
#oErrorDetail.message# and I will get that information no matter if it's an error or just something I tested for using the try/catch.

I must point out that there are differences (obviously) between what information I can get when I use cferror vs try/catch. This is simply solved by testing if certain variables are defined.

Expand|Select|Wrap|Line Numbers
  1. <cfif IsDefined("oErrorDetail.template")>
  2. <tr>
  3.     <td class="label" nowrap="nowrap"><strong>Occurred in Template &nbsp; </strong></td>
  4.     <td>#oErrorDetail.template#</td>
  5. </tr>
  6.  
  7. </cfif>        
In the previous code, only if template in the oErrorDetail object is defined then we will get an email with that info. Otherwise, it will ignore it. This is because only cferror has that property - cfcatch, doesn't.

It took me while to figure this out. But I finally got it.

3 2636
acoder
16,027 Expert Mod 8TB
What information do you need to pass?

The error or cferror variable should contain the error info.
Nov 13 '07 #2
I wanted to get an email with information about the error. Like when and where it happened.

We're using the Fusebox framework with our app.

What I did to solve this was that I created a an cferror.cfm template/component. In that template I created an object and called it oErrorDetails. Now, there are two ways that information is going to get passed into that object. One is if an error occurs and another is a using a try/catch.

The component is called Alerts.

When an error occurs I don't have to worry about because it will take care of itself by calling the cferror template(because that's the template specified to handle errors). But I can also use that component with my try/catch. For example:

Expand|Select|Wrap|Line Numbers
  1. <cftry>
  2.         <cfset Variables.temp = Variables.oStaffMember.load(Variables.nAdTeacherID) />
  3.     <cfcatch type="API.LXD.Validation">
  4.         <cfset Variables.temp = Request.oClientError.setError("noStaffMember", "A Staff Member ID has not been loaded.") />
  5.  
  6.         <cfinvoke component="cfc.utility.facade.Alert" method="send" returnvariable="success">
  7.             <cfinvokeargument name="oFusebox" value="#myfusebox#" />
  8.             <cfinvokeargument name="oClientError" value="#request.oClientError#" />
  9.             <cfinvokeargument name="oErrorDetail" value="#cfcatch#" />
  10.         </cfinvoke>
  11.     </cfcatch>
  12. </cftry>
I passed the information contained in "cfcatch" to the component using cfinvokeargument.

It's great because the component emails me information about the error like:
#oErrorDetail.message# and I will get that information no matter if it's an error or just something I tested for using the try/catch.

I must point out that there are differences (obviously) between what information I can get when I use cferror vs try/catch. This is simply solved by testing if certain variables are defined.

Expand|Select|Wrap|Line Numbers
  1. <cfif IsDefined("oErrorDetail.template")>
  2. <tr>
  3.     <td class="label" nowrap="nowrap"><strong>Occurred in Template &nbsp; </strong></td>
  4.     <td>#oErrorDetail.template#</td>
  5. </tr>
  6.  
  7. </cfif>        
In the previous code, only if template in the oErrorDetail object is defined then we will get an email with that info. Otherwise, it will ignore it. This is because only cferror has that property - cfcatch, doesn't.

It took me while to figure this out. But I finally got it.
Nov 13 '07 #3
acoder
16,027 Expert Mod 8TB
Glad you got it working and thanks for posting a detailed solution. Good job!
Nov 13 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Daniel Schwab | last post by:
Hi I have a C# component which needs to be accessed from ASP-Pages (not .net, old-style-asp). I cannot convert the asp pages to aspx pages at this time! They need to remain in ASP for a while....
1
by: int | last post by:
I have a code behind page that uses a struct that's declared inside of it in order to pass information between the methods that are also defined inside the code behind page. However, I want to...
7
by: TJ | last post by:
In C# how do you achieve pass-by-reference property declarations in the Type Library? I am writing a COM Class Library that must mimick an existing library for which the only information is the...
1
by: kpg | last post by:
Hi All, I have an asp.net project that uses an ActiveX component on the server side and I would like the login page to show the version number of this component. The ActiveX component is...
0
by: Bill | last post by:
If I have a webbrowser component in my app (created with studio 2003), and the user clicks a link which does a window.open from javascript, how can I create a new IE process and pass the session...
5
by: slowmotiongenius | last post by:
All- I have established an adodb recordset in my code-behind, and I need to pass it to the aspx file. I can't seem to figure out if there is a way to do this. I see you can pass a string over...
3
by: Girish Kanakagiri | last post by:
Hi, Can anyone please provide me the info or the link for the following Requirements. When to use COM / DCOM How to Develop / Debug COM component What is Component Service
6
by: Laphan | last post by:
Hi All I can't get round this because it's a local government thing, but I've done a CMS for a school (in ASP classic) that allows them to upload gifs, jpgs, pdfs and docs to their site for the...
1
by: Igor Ladnik | last post by:
We are dealing with .NET server component and COM clients written with VB6 and VBScript. And there are some problems we faced (please see code below). 1. Managed type System Drawing.Color is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.