Error Handling With Fusebox Presentation By Eron Cohen.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Web Applications Development Using Coldbox Platform Eddie Johnston.
Web Development in Microsoft Visual Studio Slide 2 Lecture Overview Introduce Visual Studio 2013 Create a first ASP.NET application.
Server-Side vs. Client-Side Scripting Languages
Tips and Techniques Tips re: errors Obviously, the best approach to reducing bugs is to code to a design and perform testing at incremental stages. However.
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
DT228/3 Web Development JSP: Directives and Scripting elements.
Advanced Java Course Exception Handling. Throwables Class Throwable has two subclasses: –Error So bad that you never even think about trying to catch.
Java web development Servlet & Java server pages.
Exceptions. Many problems in code are handled when the code is compiled, but not all Some are impossible to catch before the program is run  Must run.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
PHP: Hypertext Processor Fred Durao
Creating a Simple Page: HTML Overview
Object Oriented Software Development
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Introduction to the Enterprise Library. Sounds familiar? Writing a component to encapsulate data access Building a component that allows you to log errors.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Server- Side technologies Client-side vs. Server-side scripts PHP basic ASP.NET basic ColdFusion.
1 Web Based Programming Section 6 James King 12 August 2003.
Lecture Note 3: ASP Syntax.  ASP Syntax  ASP Syntax ASP Code is Browser-Independent. You cannot view the ASP source code by selecting "View source"
DAT602 Database Application Development Lecture 14 HTML.
Page Layout and Navigation in ColdFusion Jon Brundage CF Developer / Accessibility and Section 508 Consultant MDCFUG April 2003.
1 CSC241: Object Oriented Programming Lecture No 27.
The Art of Debugging Shlomy Gantz 02/13/01MDCFUG.
Exception Handling MDCFUG 6/12/2007 David Lakein Programmer / Analyst TeraTech Inc.
Software Architecture for ColdFusion Developers Unit 4: Application Events and Global Variables.
CSCI 6962: Server-side Design and Programming Validation Tools in Java Server Faces.
COLD FUSION Deepak Sethi. What is it…. Cold fusion is a complete web application server mainly used for developing e-business applications. It allows.
Learning Web Design: Chapter 4. HTML  Hypertext Markup Language (HTML)  Uses tags to tell the browser the start and end of a certain kind of formatting.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
‘Tirgul’ # 7 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #7.
HTML Internet Basics & Beyond. What The Heck Is HTML? HTML is the language of web pages. In order to truly understand HTML, you need to know a little.
Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor
CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
Advanced ColdFusion: Error Handling Mosh Teitelbaum evoch, LLC.
Application.cfm tips and Tricks Michael Smith President TeraTech, Inc ColdFusion, database & VB custom development and training.
Dynamic Debug Output and Error Handling in CF5 and CFMX November 12, 2002 By Douglas M. Smith Application Architect for Teratech, Inc.
CF Pest Control By Shlomy Gantz President, BlueBrick Inc. Presented by Sandra Clark
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
PHP Error Handling & Reporting. Error Handling Never allow a default error message or error number returned by the mysql_error() and mysql_errno() functions.
PHP Error Handling Section :I Source: 1.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
Compare and Contrast : Blackboard & a Personal Web Page www3.ltu.edu/~s_schneider/howto/faculty.htm You’ll find this presentation (and another) here :
The Need for Speed! Steve Nelson. Internet Startup Failure 2000 More Internet startups failed this year than ever before Why did this happen? How can.
Locking In CFML. Locking in CFML - Why - How - What - When } to lock? Understand Locking.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
Fusebox Not Just For Breakfast Anymore! An Introduction to Fusebox Author: Fred T. Sanders, Instant Knowledge Some Content unscrupulously taken from Steve.
Lecture 4 Page 1 CS 111 Online Modularity and Memory Clearly, programs must have access to memory We need abstractions that give them the required access.
Error Handling Michael Smith President TeraTech, Inc ColdFusion, Database & VB custom development
Cool CF Debugging Shlomy Gantz 07/29/01CF_ODYSSEY.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Data Virtualization Tutorial: Introduction to SQL Script
Programming Assignment #1
Intro to PHP & Variables
Introduction to JavaScript
Exception Handling .NET MVC
A second look at JavaScript
Topics Introduction to File Input and Output
Building Web Applications
Introduction to JavaScript
Topics Introduction to File Input and Output
Presentation transcript:

Error Handling With Fusebox Presentation By Eron Cohen

What We’ll Learn How to handle Errors with ColdFusion: CFERROR CFTRY/CFCATCH/CFTHROW A little bit about the Fusebox method of writing ColdFusion applications How does it work? Why is it so good for catching and logging errors?

CFERROR vs. CFTRY There are two basic ways to handle errors with CFML: CFERROR and CFTRY. CFTRY is more flexible than CFERROR. CFERROR is a bit easier because its more “cut and dry.” With CFERROR processing usually stops when you throw an error, with CFTRY, processing can continue. CFTRY allows for a finer level of control than CFERROR. CFTRY allows you to handle the error on the same template that threw the error. For a Fusebox application, you’ll probably want to use CFTRY. CFERROR isn’t as flexible and doesn’t lend itself to FUSEBOX as well.

How To Use CFERROR The CFERROR tag is normally used in the APPLICATION.CFM file so that it will be included at the top of every Cold Fusion template. Syntax: If an error is thrown during the execution of a page that is within the realm of your APPLICATION.CFM, the template that you specified will execute. Depending on what type of CFERROR you specify, there are certain restrictions on how you can handle the error. For instance, if you specify the type “REQUEST”, your error handling template cannot contain any CFML tags…it can only output a predetermined list of variables combined with HTML. On the other hand, if you specify the type “Exception” you’ll have the ability to utilize the full-range of CFML functions.

Example of how to use CFERROR APPLICATION.CFM: REQUESTERR.CFM: There was an error: Date/Time: #Error.DateTime# IP Address: #Error.RemoteAddress# Referring Page: # Error. HTTP_REFERER# Offending Script: #error.script_name#"

How to Use CFTRY/CFCATCH For every pair, there needs to be at least one. The syntax is something like:... Add code here.... Add exception processing code here.... Add exception processing code here

Types of Exceptions Used With CFCATCH These are the types of exceptions you can specify in your CFCATCH statement: Application, Database, Template, Security, Object, MissingInclude, Expression, Lock, Custom_type, Any (default). – You can have multiple CFCATCHES to handle different types of errors. – ColdFusion tests CFCATCH types in the ORDER THEY APPEAR on your page! – Type=“Any” is the catch all. It will execute in the face of any type of error. Put that one at the end of your block of CFCATCHES (or if you only specify one CFCATCH, use this one!). Also keep in mind that they really do mean “ANY!” kind of error. – If an error is thrown for a type of error that has no CFCATCH to handle it, it will throw its default error. – The “Custom” and “Application” types of errors are used with the CFTHROW tag.

Variables Exposed to CFCATCH A CFCATCH block may contain certain informational variables. Here are a few of them: Type -- Exception type, as specified in CFCATCH. Message -- The exception's diagnostic message, if one was provided. If no diagnostic message is available, this is an empty string. Detail -- A detailed message from the CFML interpreter. This message, which contains HTML formatting, can help determine which tag threw the exception. TagContext -- The tag stack: the name and position of each tag in the tag stack, and the full path names of the files that contain the tags in the tag stack. See the note that follows this list for more information. NativeErrorCode -- TYPE=Database only. The native error code associated with this exception. Database drivers typically provide error codes to assist diagnosis of failing database operations. If no error code was provided, the value of NativeErrorCode is -1. SQLSTATE -- TYPE=Database only. The SQLState associated with this exception. Database drivers typically provide error codes to assist diagnosis of failing database operations. If no SQLState value was provided, the value of SQLSTATE is -1. ErrNumber -- TYPE=Expression only. Internal expression error number. MissingFileName -- TYPE=MissingInclude only. Name of the file that could not be included. ErrorCode -- TYPE=Custom type only. A string error code. ExtendedInfo -- TYPE=APPLICATION and custom only. A custom error message.

Leverage Your Error Handling with CFTHROW Now that you’ve designed such great error handlers, why not recycle them using CFTHROW? When a condition occurs in your application, that normally would not throw a ColdFusion error, you can “simulate” one with CFTHROW. CFTHROW allows you to send ColdFusion to one of three kinds of CFCATCH error handlers: CFCATCH TYPE= "custom_type " CFCATCH TYPE= "APPLICATION " CFCATCH TYPE= "ANY " Syntax:

A Brief Explanation of Fusebox The Fusebox method is simply a style of writing code as a “circuit application.” Depending what “fuseaction” is specified, a different CFSWITCH is thrown. Code is modular so it is easy to reuse. Code is self-documenting and easier to read. Code is written to a documented standard so the next time someone works on the code it will be easy to understand.

A Simple Fusebox Example INDEX.CFM:

Fusebox is perfect for trapping errors! One of the great things about the Fusebox methodology is that all actions for the entire application are controlled through one file: your main index.cfm. This means that if you want to trap errors you have a single point of attack to do so. Lets look at my example index.cfm printout…

Gotchas & Mentionables Gotcha: In ColdFusion 4.5 and before, the error handling templates for CFERROR cannot contain any CFML, just a few predetermined variables! Later versions of ColdFusion have added flexibility for some types of CFERRORs. Gotcha: Make sure you don’t have any errors in your CFCATCH. CFCATCH exceptions are not handled by the CFTRYs that enclose it. Mentionable: You can customize your default Cold Fusion and Web server error messages. Sick of seeing ugly white screen 404 errors? You can substitute your own in the webserver software. Cold Fusion Administrator also provides a preference setting for handling problems:

Creative ways to use CFTRY/CFCATCH We log any errors that occur on our website in a database for review at a later time. It means we don’t have to rely on an end user to describe what happened. Problem with CFPOP solved by CFTRY Big Query/little query