Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default cfthrow/cfcatch

    Is the code after <cfthrow> supposed to execute? If my page, I have code
    after the <cfthrow> that I don't want to execute.

    How do I stop this from happening?




    <CFTRY>
    <cffile action="UPLOAD" filefield="#fileNum#"
    destination="#LibraryDirectory#" nameconflict="MAKEUNIQUE">
    <cfif Find(" ", File.ServerFile) OR Find("&", File.ServerFile)>
    <cfset newfilename = Replace(File.ServerFile, " ", "", "ALL")>
    <cfset newfilename = Replace(newfilename, "&", "", "ALL")>

    <cffile action="RENAME" source="#LibraryDirectory##File.ServerFile#"
    destination="#LibraryDirectory##newfilename#">
    <cfelse>
    <cfset newfilename = "#File.ServerFile#">
    </cfif>
    <cfif file.ServerFileExt IS NOT "pdf" OR NOT ISDefined("file.ServerFileExt")
    OR NOT FIND("pdf", newfilename, 1)>
    <cfthrow message="The MIME type of the uploaded file, '#file.ContentType#',
    was not accepted by the server." type="file.contentType" detail="Only files of
    type 'application/pdf' can be uploaded.">
    </cfif>

    --- other code --

    <CFCATCH TYPE="file.ContentType">

    </CFCATCH>
    </CFTRY>

    shenry Guest

  2. Similar Questions and Discussions

    1. Flash Remoting and CFTHROW
      We are using FlashRemoting and CF7. And are experiencing a weird problem. If we use a variable in the <cfthrow> message attribute, the exception...
    2. cfdump on cfcatch
      sometimes i can successfully cfdump the cfcatch variable. other times, when I try to dump it, it says "unknown type". any ideas what's up with...
    3. Using CFTHROW to catch invalid email addresses
      I'm working on a helpdesk system that sends notification emails to users and support consultants whenever they updated certain fields in the forms....
    4. Cfcatch include
      I have a cfcatch routine that I am including in my forms that emails the administrator when an error occurs. I would like to have this code in a...
    5. <CFTRY> <CFCATCH>
      I would like to know whether there's a way to obtain the SQL statement via cfcatch's like I see when I use cferror or default to the error message. ...
  3. #2

    Default Re: cfthrow/cfcatch

    In this excerpt, if testBooloean is true, code block B will run and code block A
    will not; if testBooloean is false, code block A will run and code block B
    will not.

    <CFTRY>
    <cfif testBoolean>
    <cfthrow message="x" type="y">
    </cfif>
    <!--- code block A --->
    <CFCATCH TYPE="y">
    <!--- code block B --->
    </CFCATCH>
    </CFTRY>

    BKBK Guest

  4. #3

    Default Re: cfthrow/cfcatch

    Your cfthrow is inside a cfif tag. How do you know it is actually running?

    Originally posted by: shenry
    Is the code after <cfthrow> supposed to execute? If my page, I have code
    after the <cfthrow> that I don't want to execute.

    How do I stop this from happening?






    Dan Bracuk Guest

  5. #4

    Default Re: cfthrow/cfcatch

    I know it's running, because I put a <cfmail> tag inside the <cfcatch> and I'm getting the emails.

    I solved the problem by putting a <cfabort> right before </cfcatch>.

    Thanks for your responses.
    shenry Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139