• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Using CFThrow to rethrow?

Advocate ,
Dec 05, 2007 Dec 05, 2007

Copy link to clipboard

Copied

I was wondering if it's possible to, or if anyone has emulated a <CFRETHROW> with a <CFTHROW> call?

Here's basically what I'm trying to accomplish:
TOPICS
Advanced techniques

Views

724

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 05, 2007 Dec 05, 2007

Copy link to clipboard

Copied

I have not used this personally, but it appears to work

<cfif myCfCatchActive>
<cfthrow object="#myCFCatch.Cause#">
</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 05, 2007 Dec 05, 2007

Copy link to clipboard

Copied

My ears popped up, and I optimistically tried the myCFCatch.Cause method and bummer -- "Element CAUSE is undefined in MYCFCATCH"

What version of CF are you using? I'm using MX8.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 05, 2007 Dec 05, 2007

Copy link to clipboard

Copied

Weird, I am using CF8 as well. Here is the test code I used

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 05, 2007 Dec 05, 2007

Copy link to clipboard

Copied

If perhaps you meant MX7, try using RootCause instead.

<cfif myCfCatchActive>
<cfthrow object="#myCFCatch.RootCause#">
</cfif>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 05, 2007 Dec 05, 2007

Copy link to clipboard

Copied

Ah, you are right that I am using MX7 -- I have MX8 on my notebook and MX7 on my desktop - my bad. RootCause is also undefined for my MX7 test. I have not tried this test on 8 yet.

BTW, my test case is as follows:

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Dec 05, 2007 Dec 05, 2007

Copy link to clipboard

Copied

This is close, but not quite. It does display the correct error message, but reports the error as occuring on the <cfthrow> line. Interestingly, my test case generates a java.sql.SQLException and the error line numbers are reported correctly. So apparently, not all exceptions are alike. Perhaps coldfusion runtime exceptions (ie like coldfusion.runtime.UndefinedVariableException) are handled differently.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 06, 2007 Dec 06, 2007

Copy link to clipboard

Copied

LATEST
Thanks for the suggestion. I wish it would have worked. Maybe someone from Adobe will read this and make the Cause object work for all exception types.

Anyway, I coded around this by storing the CFCatch as shown above and modifying my error display page to use this stored copy instead of the current CFCatch copy if a specific user defined error is thrown "UnhandledException.FinalGasp", which I throw if I detect this condition in my postProcess (I'm using Fusebox).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation