Solved

CFTHROW alternative

Posted on 2011-09-22
4
465 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

19 Experts available now in Live!

Get 1:1 Help Now