Solved

CFTHROW alternative

Posted on 2011-09-22
4
470 Views
Last Modified: 2013-12-24
I need an alternate method of CFTHROW...the environment that I am in does not allow this tag.  How do I get the same result without using CFTHROW.
<cffunction name="fullDuration" returntype="struct">
   <cfargument name="startDate" type="date">
   <cfargument name="endDate" type="date">
   <cfif dateCompare(arguments.startDate, arguments.endDate) gt 0>
        <cfthrow message="StartDate cannot be greater than EndDate">
    </cfif>
</cffunction>

Open in new window

0
Comment
Question by:Lee R Liddick Jr
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
devilJinKazama earned 500 total points
ID: 36584531
if you are using it to only display messages out to the screen, you can make a custom tag to handle that and make it look pretty as well. if you dont care about how it looks you can just use cfabort to get the same ugly blue box and display the message you want

<cffunction name="fullDuration" returntype="struct">
   <cfargument name="startDate" type="date">
   <cfargument name="endDate" type="date">
   <cfif dateCompare(arguments.startDate, arguments.endDate) gt 0>
        <cfabort showerror="StartDate cannot be greater than EndDate">
    </cfif>
</cffunction>

if you do make a custom tag, it would go something like this


<cfparam name="Attributes.Message" default="">

<cfswitch expression=#thisTag.ExecutionMode#>
  <cfcase value= 'start'>
    <!--- Start tag processing --->
  </cfcase>
  <cfcase value='end'>

    put fancy HTML & design here
   
   
     <cfoutput> #attributes.Message#</cfoutput>
   
    <cfabort>
 
  </cfcase>
 
</cfswitch>
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 36584643

It seems really strange to me that they would not support cfthrow... I am curious how you verified that?   Did you get an error and they say "we don't support this.." meaning you're on your own.. or do they really mean, you can't use that tag.   I say this because the host has to catch errors, they all do... so why can't you throw on?

Did you try this...
<cfscript>
    // if you want to throw a database error:
    throw('database');
</cfscript>

0
 

Author Comment

by:Lee R Liddick Jr
ID: 36586918
gdemaria...it's a shared server restriction.
0
 
LVL 39

Expert Comment

by:gdemaria
ID: 36587079
it's an odd one...
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now