Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Getting programmatic debugging and exception handling

From: ColdFusion 9 New Features

Video: Getting programmatic debugging and exception handling

In ColdFusion 8, it's always been difficult to get good debugging and test information on production systems unless you have total control over the server running your application. But even then getting good error information involved emailing yourself errors or some other method of forcing the error information to your local machine so that it wasn't displayed to the people viewing your website. In ColdFusion 9, we get access to two more settings that will help us with our debugging. In this video, I'm going to show you how to get debugging information for your specific IP through the application CFC as well as how to enable and disable per request exception handling when you simply need to see those errors in the browser.

Getting programmatic debugging and exception handling

In ColdFusion 8, it's always been difficult to get good debugging and test information on production systems unless you have total control over the server running your application. But even then getting good error information involved emailing yourself errors or some other method of forcing the error information to your local machine so that it wasn't displayed to the people viewing your website. In ColdFusion 9, we get access to two more settings that will help us with our debugging. In this video, I'm going to show you how to get debugging information for your specific IP through the application CFC as well as how to enable and disable per request exception handling when you simply need to see those errors in the browser.

So in the Chapter2 folder, we will open robustexception.cfm. This just has a query and a dump in it. So if I preview, you can see it's dumping all of the information, but what I'd really like to be able to see is the debugging information, not just what I see from cfdump. So to do this, we will switch over to Safari and take a look at the ColdFusion Administrator. Under the debugging and logging section, in Debug Output, we are going to go ahead and enable robust exception and debugging output at the same time and submit those changes.

If I go over here to Debugging IP Addresses, we can see it already has two IP Addresses in here. I'm going to go ahead and click Add Current, just to make sure that mine is in there. So, you can see my IP Address is 1%0, so now I have my IP address in here. If I switch over to CF Builder and click on the Safari tab, you can see I now have my debugging information. So this is all well and good, but the issue with this is that now anybody with my IP, let's assume I was behind a Firewall and was just viewing my site, anybody with my IP address would be able to see the debugging information.

So let's go back to the ColdFusion Administrator and remove my IP address here. So I will select my IP and click Remove Selected and let's just make sure that that is now disappeared and yes, we can see it has now gone away. Now, what I want to be able to do is to turn that on, on a per request basis. So I go back to CF Builder and open the Application.cfc file, I can add a new this scope attribute called this.debugging IP addresses.

I can enter in a comma-separated list of IP addresses that are allowed to see debugging information. So I'm going to enter in my really long IP address here. I'll save the application.cfc, switch back to my robustexception.cfm and reload and we can now see that I can see all my debugging information. Now because this is a 'this' scope variable, I can put it inside some condition that determines when I'm allowed to see it.

So let's say if StructKeyExists(URL "showdebugging"). So, now the only time I should see debugging information is when I actually put the showdebugging URL variable into the address bar. Now because I can't manipulate the URL inside the CF Builder's preview, we will switch over to Safari and take a look there. So we'll go to localhost, Chapter2, robustexception.

You can see I'm not seeing any debugged information, but I will add showdebugging onto the end and now we can see all of our debugging information. Now, if you wanted to add multiple IP addresses to the debugging output, you could just simply put in a comma and put as many IP addresses in here as you want. Now because this list of IP addresses is like any other Cold Fusion list, they can be generated from a database, a query, some other variable however you want to set it up.

It's very easy to fill this debugging IP addresses value with what you want to see. Now the other thing we can do is also enable robust exceptions on a per request basis. So let's cause a problem here. In my robustexception.cfm, I'm going to put in a bad table name. If I switch back over to my page in Safari and reload, you can see I'm getting my big fat robustexception. So let's turn that off in the ColdFusion Administrator. Go back to Debug Output Settings and turn it off.

Keep things nice and safe in our production environment and reload this page. Now, we get our much smaller exception information but what I can do inside of my application.cfc is I'm going to put inside the same if statement. I can cfset this.Enablerobustexception = true. Now, I will switch back to Safari and take off the show debugging and load the page. You will see it's still showing the simple debug output.

Add it back and now I get my robust exception because of that new enable robust exception attribute under this scope. Now, there's two things to keep in mind using these new 'this' scope variables. The first is security. Make sure that any time you enable these that they are secured, that you can ensure that no one is going to be able to force robust exceptions or to force their IP address into your allowed list without your knowledge. The second thing to remember is security. Always, always, always lock these down.

So, in Cold Fusion 9, you now have the ability to programmatically enable debugging and exception handling on a per request basis. This will make debugging production systems much easier, but make sure that you have the proper protections in place to ensure you don't give away the secret sauce for your application.

Show transcript

This video is part of

Image for ColdFusion 9 New Features
ColdFusion 9 New Features

36 video lessons · 2909 viewers

Daniel Short
Author

 
Expand all | Collapse all
  1. 4m 30s
    1. Welcome
      53s
    2. Using the exercise files
      3m 37s
  2. 7m 48s
    1. Adding managing and comparing servers
      5m 26s
    2. Monitoring server health
      2m 22s
  3. 22m 10s
    1. Setting the default data source and SMTP
      5m 6s
    2. Getting programmatic debugging and exception handling
      5m 54s
    3. Reviewing the new onCFCRequest method
      5m 29s
    4. Using ApplicationStop()
      2m 24s
    5. Working with Server.cfc and onServerStart
      3m 17s
  4. 17m 45s
    1. Using ternary and chained operations
      5m 46s
    2. Using New and Import
      4m 2s
    3. Reviewing CFScript enhancements
      7m 57s
  5. 20m 23s
    1. Building with implicit getters and setters
      4m 26s
    2. Working with LOCAL scope in functions
      4m 35s
    3. Serializing objects
      6m 6s
    4. Writing components in CFScript
      5m 16s
  6. 19m 27s
    1. Getting started with ORM
      5m 51s
    2. Logging ORM activity
      2m 13s
    3. Saving objects to the database
      6m 10s
    4. Defining table relationships
      5m 13s
  7. 16m 59s
    1. Caching page fragments
      5m 29s
    2. Managing the cache
      4m 48s
    3. Working with in-memory files using VFS (RAM disks)
      6m 42s
  8. 12m 39s
    1. Working with Excel spreadsheets
      4m 56s
    2. Working with Word documents
      4m 4s
    3. Working with PowerPoint presentations
      3m 39s
  9. 28m 58s
    1. Loading Google maps with markers onto a page
      4m 53s
    2. Adding a Flash movie with the built-in FLV player
      2m 14s
    3. Using multi-file upload control
      6m 7s
    4. Building a progress indicator
      3m 37s
    5. Working with accordion layouts
      3m 18s
    6. Showing information with data grid enhancements
      5m 1s
    7. Informing users with Confirm Alert and Prompt dialog boxes
      3m 48s
  10. 9m 8s
    1. Accessing IMAP accounts
      6m 31s
    2. Working with the new array functions
      2m 37s
  11. 15s
    1. Goodbye
      15s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed ColdFusion 9 New Features.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.