18 Replies Latest reply on Nov 1, 2006 10:36 AM by Newsgroup_User

    Building the ultimate error email...

    Level 7
      Hello,
      I'm using CFERROR to catch exceptions and generate an email to myself. I
      use to have all the basic #error.foo# variables in the email, but I wanted
      more. So I figured out how you can include most of what is in the
      classic.cfm template located in the web-inf/debug/ folder and it will pretty
      much send you all the normal debug output you get on a web page with an
      error and debug turned on.

      Now for the catch, this works great for me with the exception of the newer
      CFMX style debug output you see at the top of your debug output. This is
      the area where CF actually will display several lines of code in and around
      the offending error. For some reason, this port of the debug output is not
      available in the classic.cfm file and I can't figure out where to find it.

      Has anyone done this? I'm actually very happy just getting the classic CF 5
      debut output, but I'd love even more to have the CFMX style output as well.
      Thanks so much!

      ...Brad

      PS. I'm using CFMX 7.x on Linux.



        • 1. Re: Building the ultimate error email...
          MikerRoo Level 1
          The tagContext array gives the line numbers of the calling tree.
          The first entry is for the offending code.

          The line number should be all you need. You can read the file if you really want to display the code.
          • 2. Re: Building the ultimate error email...
            Level 7
            Thanks for your reply, but that isn't what I'm after. I'm specifically
            after the information in the attached screen shot:

            http://brad.melendy.com/cf-error.jpg

            I have all the other debug info in my email that comes after the grey box
            (all the "classic"
            debug info). But I can't figure out how to capture the information in the
            above url. Any help would be greatly appreciated.

            ...Brad


            "MikerRoo" <webforumsuser@macromedia.com> wrote in message
            news:ehbnvg$p41$1@forums.macromedia.com...
            The tagContext array gives the line numbers of the calling tree.
            The first entry is for the offending code.

            The line number should be all you need. You can read the file if you
            really
            want to display the code.



            • 3. Re: Building the ultimate error email...
              MikerRoo Level 1
              What do you mean, you "have all the other debug info in my email that comes after the grey box"?

              Everything in the url you posted is "in the grey box".

              Furthermore, all of that information is available in the cferror struct.

              What, exactly, SPECIFICALLY, are you missing?
              • 4. Re: Building the ultimate error email...
                Level 7
                Sorry for any confusion. I want to include ALL debug info in my email. I
                have all the "classic" info included and working but I want the newer "MX"
                info which is what is in the grey box. In this screen shot, I inclue the
                full debug from an error and have annotaded it with what I have in my email,
                and what I don't have in my email (the grey box data).

                http://brad.melendy.com/cf-error-full.jpg (might need to save to your hard
                drive or expand to full size for proper viewing)

                Anyway, I have looked high and low and just can't find the code responsible
                for the debug info you see in the grey box. I have read that much of this
                information is burried deep inside the error structure, but I don't want to
                re-invent the wheel and write a bunch of new code or parse a big XML file.
                I want to copy and paste as I have with the classic.cfm template. (That's
                why I'm using Coldfusion after all.) It is obviously already formatted
                nicely someplace. Thanks again.

                ...Brad

                "MikerRoo" <webforumsuser@macromedia.com> wrote in message
                news:ehjbap$qm3$1@forums.macromedia.com...
                What do you mean, you "have all the other debug info in my email that comes
                after the grey box"?

                Everything in the url you posted is "in the grey box".

                Furthermore, all of that information is available in the cferror struct.

                What, exactly, SPECIFICALLY, are you missing?



                • 5. Re: Building the ultimate error email...
                  dave.cozens
                  What I've one previously when using CFERROR is to loop over the available structures: -
                  cferror,variables,request,session,application,server,client,url,form,cgi
                  and output the contents into an HTML string (using CFSavecontent).

                  From there I can either email it of (very messy with multiple member support teams) or (this is my preferred option) create an html file (write it to the server) and email out a reference to the file.

                  i.e.
                  1. Error occurs
                  2. Build detailed html page (use javascript "tabs" and cfdump).
                  3. Write file with unique reference using time, date, server etc.
                  4. Email support email with cferror detail and the unique reference as a hyperlink.

                  If you take it further you can categorise errors, write them to a database and produce statistics. Which is very useful if you've got some legacy code and you need to prioritise your errors.
                  • 6. Re: Building the ultimate error email...
                    MaryJo Level 1
                    Definitely keep in mind as well issues with security if you plan to email error messages. If you use any kind of login security such that secure information would appear in any of these scopes or in a query, etc. writing the errors to the disk and then securing them in some way is often the best approach.
                    • 7. Re: Building the ultimate error email...
                      dave.cozens Level 1
                      When I've done this I tend to take it a step further and build a small error viewing back end attached to the admin functions.

                      I also prefer to log the errors in a database since they're easier to analyse than plain text .html files. On top of which if you're running clustered it works a treat.

                      But yes, you certainly don't want users getting access to that level of data.

                      And if it's an internal system you can wig the users out by phoning them and saying "Hi xxxx, you just has an error doing yyyy didn't you" etc. Which is kinda amusing...
                      • 8. Re: Building the ultimate error email...
                        Level 7
                        Thanks Dave,
                        That works well except I can't seem to find the structure that has the
                        information I am looking for. All the variables at already nicely formatted
                        in "classic.cfm" but the newer MX style extra debug info you get isn't in
                        that template and I'm still looking. Also, I'm trying to keep this simple
                        and avoid writing a whole "mini-application" to do this. Copying and
                        pasting the contents of classic.cfm into my <cfmail> tag works so well, but
                        I just want to find the extra debug output that you get at the top of your
                        error screen on an MX server like this:

                        http://brad.melendy.com/cf-error-full.jpg

                        I'm still hopeful that someone out there knows where the the code that
                        builds this portion of the debug output exists. Thanks again.

                        ...Brad

                        "dave.cozens" <webforumsuser@macromedia.com> wrote in message
                        news:ei4vud$1uj$1@forums.macromedia.com...
                        What I've one previously when using CFERROR is to loop over the available
                        structures: -
                        cferror,variables,request,session,application,server,client,url,form,cgi
                        and output the contents into an HTML string (using CFSavecontent).

                        From there I can either email it of (very messy with multiple member
                        support
                        teams) or (this is my preferred option) create an html file (write it to the
                        server) and email out a reference to the file.

                        i.e.
                        1. Error occurs
                        2. Build detailed html page (use javascript "tabs" and cfdump).
                        3. Write file with unique reference using time, date, server etc.
                        4. Email support email with cferror detail and the unique reference as a
                        hyperlink.

                        If you take it further you can categorise errors, write them to a database
                        and
                        produce statistics. Which is very useful if you've got some legacy code and
                        you
                        need to prioritise your errors.


                        • 9. Re: Building the ultimate error email...
                          Level 7
                          Thanks for the input Mary, I'll keep that in mind.

                          ...Brad

                          "MaryJo" <maryjo@cfwebstore.com> wrote in message
                          news:ei50fn$2ib$1@forums.macromedia.com...
                          Definitely keep in mind as well issues with security if you plan to email
                          error
                          messages. If you use any kind of login security such that secure information
                          would appear in any of these scopes or in a query, etc. writing the errors
                          to
                          the disk and then securing them in some way is often the best approach.


                          • 10. Re: Building the ultimate error email...
                            MaryJo Level 1
                            quote:

                            Originally posted by: dave.cozens
                            When I've done this I tend to take it a step further and build a small error viewing back end attached to the admin functions.

                            I also prefer to log the errors in a database since they're easier to analyse than plain text .html files. On top of which if you're running clustered it works a treat.

                            That's pretty much how I did it in CFWebstore, made it part of the admin. I still prefer to write out the files versus using the DB (mainly since it's common for new users to have DB setup problems!) but either certainly works fine. By using .cfm files, it's easy to both put them behind SSL as well as protect them through the CF application.

                            Brad - don't know where that exact code would come from. But the error scope should have most of the additional information you would need.
                            • 11. Re: Building the ultimate error email...
                              Level 7
                              Thanks MaryJo, you would think that the cferror variables would have this
                              info, but they don't or at least I haven't been able to reproduce the
                              information I am after using those variables. :-(

                              "MaryJo" <maryjo@cfwebstore.com> wrote in message
                              news:ei7tq8$kld$1@forums.macromedia.com...
                              quote:

                              Originally posted by: dave.cozens
                              When I've done this I tend to take it a step further and build a small
                              error
                              viewing back end attached to the admin functions.

                              I also prefer to log the errors in a database since they're easier to
                              analyse
                              than plain text .html files. On top of which if you're running clustered it
                              works a treat.

                              That's pretty much how I did it in CFWebstore, made it part of the admin. I
                              still prefer to write out the files versus using the DB (mainly since it's
                              common for new users to have DB setup problems!) but either certainly works
                              fine. By using .cfm files, it's easy to both put them behind SSL as well as
                              protect them through the CF application.

                              Brad - don't know where that exact code would come from. But the error
                              scope
                              should have most of the additional information you would need.



                              • 12. Re: Building the ultimate error email...
                                Giri_sayee
                                Brad,
                                I believe what you are looking for is called the robust information. This will not be in the error structre.

                                The code for this would be in web_inf/exception/detail.cfm.

                                I use a customized version with very minimal changes from the original version and it works like a charm.

                                If you would want to use the inbuilt version - you should use it as a custom tag.
                                <cf_detail error="#error#" >
                                </cf_detail> .

                                This would display the robust information and you can even modify the number of surrounding lines you would need.

                                You would need the logic from detail.cfm,gettemplate.cfm,errorcontext.cfm and a couple of exception XML files in the
                                /web_inf/exception directory if you would want to build your own.

                                Hope this helps.

                                Just Curious -I tried to use classic.cfm debug info in my error log , but was unsuccessful since i disabled debugging in CF server.

                                How are you doing this? Can you pull out debug info even when debugging is turned off?
                                • 13. Re: Building the ultimate error email...
                                  Giri_sayee Level 1
                                  Brad,
                                  I believe what you are looking for is called the robust information. This will not be in the error structre.

                                  The code for this would be in web_inf/exception/detail.cfm.

                                  I use a customized version with very minimal changes from the original version and it works like a charm.

                                  If you would want to use the inbuilt version - you should use it as a custom tag.
                                  <cf_detail error="#error#" >
                                  </cf_detail> .

                                  This would display the robust information and you can even modify the number of surrounding lines you would need.

                                  You would need the logic from detail.cfm,gettemplate.cfm,errorcontext.cfm and a couple of exception XML files in the
                                  /web_inf/exception directory if you would want to build your own.

                                  Hope this helps.

                                  Just Curious -I tried to use classic.cfm debug info in my error log , but was unsuccessful since i disabled debugging in CF server.

                                  How are you doing this? Can you pull out debug info even when debugging is turned off?
                                  • 14. Building the ultimate error email...
                                    Giri_sayee Level 1
                                    Apologies - didn't mean to spam . I 'm just click happy today.
                                    • 15. Re: Building the ultimate error email...
                                      Level 7
                                      Hi Giri,
                                      Thanks for much for your information, I'm going to look into detail.cfm
                                      asap. I am tricking classic.cfm by manually setting the InDebugMode
                                      variable at the top of my template like this:

                                      <cfparam name="InDebugMode" default="True">

                                      It normally does a check for that variable based from the settings in the
                                      CFAdministrator, but I force it to TRUE and it works great.

                                      I'm going to start playing with detail.cfm. Thanks again!

                                      ...Brad


                                      "Giri sayee" <webforumsuser@macromedia.com> wrote in message
                                      news:ei8aa1$6pj$1@forums.macromedia.com...
                                      Brad,
                                      I believe what you are looking for is called the robust information. This
                                      will not be in the error structre.

                                      The code for this would be in web_inf/exception/detail.cfm.

                                      I use a customized version with very minimal changes from the original
                                      version
                                      and it works like a charm.

                                      If you would want to use the inbuilt version - you should use it as a
                                      custom
                                      tag.
                                      <cf_detail error="#error#" >
                                      </cf_detail> .

                                      This would display the robust information and you can even modify the
                                      number
                                      of surrounding lines you would need.

                                      You would need the logic from detail.cfm,gettemplate.cfm,errorcontext.cfm
                                      and
                                      a couple of exception XML files in the
                                      /web_inf/exception directory if you would want to build your own.

                                      Hope this helps.

                                      Just Curious -I tried to use classic.cfm debug info in my error log , but
                                      was
                                      unsuccessful since i disabled debugging in CF server.

                                      How are you doing this? Can you pull out debug info even when debugging is
                                      turned off?


                                      • 16. Building the ultimate error email...
                                        Giri_sayee Level 1
                                        Huh.. It looks like the getDebugger Method of the Debugging factory class is not accessible unless
                                        Debugging is turned on.Maybe i'm missing something that's obvious - but I don't see how setting the variable would generate Debug output.

                                        Can you please explain?

                                        Thanks!
                                        • 17. Re: Building the ultimate error email...
                                          Giri_sayee Level 1
                                          What i mean is - the server doesn't produce debugging output unless debugging is turned on the server - I don't see how this could work unless you turn debugging on the server and override with cfsetting not to show debug output- Then the server would produce debugging output which could be used for the error emails.

                                          Am i missing something here?
                                          • 18. Re: Building the ultimate error email...
                                            Level 7
                                            I'm confused myself. I recently found out that it seems using the code from
                                            classic.cfm in my error emails actually causes the server to behave the
                                            opposite of having debug turned on in the cold fusion administrator.
                                            Depending on the settings, I can get a wonderful html formatted email with
                                            all the debugging info, and other times I get only the debug output on the
                                            screen regardless of if CFERROR is being used. I'm still trying to figure
                                            this out but I believe I'm doing something that isn't supported so whether
                                            it will work correctly is up in the air.


                                            "Giri sayee" <webforumsuser@macromedia.com> wrote in message
                                            news:eiag6g$nrt$1@forums.macromedia.com...
                                            What i mean is - the server doesn't produce debugging output unless
                                            debugging
                                            is turned on the server - I don't see how this could work unless you turn
                                            debugging on the server and override with cfsetting not to show debug
                                            output-
                                            Then the server would produce debugging output which could be used for the
                                            error emails.

                                            Am i missing something here?