Tracing, Logging, and Error Handling MacDonald Ch. 8 MIS 424 MIS 424 Professor Sandvig Professor Sandvig.

Slides:



Advertisements
Similar presentations
Exceptions Don’t Frustrate Your User – Handle Errors KR – CS 1401 Spring 2005 Picture – sysprog.net.
Advertisements

An Introduction to Java Programming and Object- Oriented Application Development Chapter 8 Exceptions and Assertions.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 15: Exception Handling.
Try…Catch…Finally Blocks ( continued ) Generic catch clause –Omit argument list with the catch –Any exception thrown is handled by executing code within.
C# Programming: From Problem Analysis to Program Design1 Debugging and Handling Exceptions C# Programming: From Problem Analysis to Program Design 3 rd.
Chapter 16: Exception Handling C++ Programming: From Problem Analysis to Program Design, Fifth Edition.
Objectives In this chapter you will: Learn what an exception is Learn how to handle exceptions within a program See how a try / catch block is used to.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 16: Exception Handling.
Microsoft VB 2005: Reloaded, Advanced Chapter 5 Input Validation, Error Handling, and Exception Handling.
Caching MacDonald Ch. 26 MIS 424 MIS 424 Professor Sandvig Professor Sandvig.
Working with ASP Pages. Slide 2 The Tag (1) Remember that most ASP.NET pages contain a single tag with the runat attribute set It’s possible to have multiple.
Web Development in Microsoft Visual Studio Slide 2 Lecture Overview Introduce Visual Studio 2013 Create a first ASP.NET application.
ASP.NET Security MacDonald Ch. 18 MIS 424 MIS 424 Professor Sandvig Professor Sandvig.
Exceptions Used to signal errors or unexpected situations to calling code Should not be used for problems that can be dealt with reasonably within local.
Configuring Applications MacDonald Ch. 9 MIS 424 MIS 424 Professor Sandvig Professor Sandvig.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Security in SQL Jon Holmes CIS 407 Fall Outline Surface Area Connection Strings Authenticating Permissions Data Storage Injections.
Advanced Java Course Exception Handling. Throwables Class Throwable has two subclasses: –Error So bad that you never even think about trying to catch.
Creating & Consuming Web Services MIS 424 MIS 424 Professor Sandvig Professor Sandvig.
Developing an ASP.NET Application and using the Mobile Internet Toolkit Bart Vande Ghinste Developer Consultant Microsoft Belux.
Microsoft ® Official Course Monitoring and Troubleshooting Custom SharePoint Solutions SharePoint Practice Microsoft SharePoint 2013.
IT533 Lectures Configuring, Deploying, Tracing and Error Handling.
Web Form Fundamentals MacDonald Ch. 5 MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
MIS 3200 – Unit 6.2 Learning Objectives How to move data between pages – Using Query Strings How to control errors on web pages – Using Try-catch.
.NET Validation Controls MacDonald Ch. 8 MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
1 Defensive Programming and Debugging (Chapters 8 and 23 of Code Complete) Tori Bowman CSSE 375, Rose-Hulman September 21, 2007.
ASP.NET Programming with C# and SQL Server First Edition Chapter 6 Debugging and Error Handling.
Understanding Events and Exceptions Lesson 3. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understand events and event handling Understand.
Tracing 1www.tech.findforinfo.com. Contents Why Tracing Why Tracing Tracing in ASP.NET Tracing in ASP.NET Page Level tracing Page Level tracing Application.
Maintaining State MacDonald Ch. 9 MIS 324 MIS 324 Professor Sandvig Professor Sandvig.
Java Programming: Guided Learning with Early Objects
Effective Security in ASP.Net Applications Jatin Sharma: Summer 2005.
Introduction to Exception Handling and Defensive Programming.
Visual Basic.NET BASICS Lesson 5 Exponentiation, Order of Operations, and Error Handling.
Global.asax file. Agenda What is Global.asax file How to add the Global.asax file What are the default events available Explanation to Application_Level.
Chapter 14: Exception Handling. Objectives In this chapter, you will: – Learn what an exception is – Learn how to handle exceptions within a program –
Database Handling, Sessions, and AJAX. Post Back ASP.NET Functionality The IsPostBack method in ASP.NET is similar to the BlackBerry.refresh method –IsPostBack.
Slide 1 ASP Authentication There are basically three authentication modes Windows Passport Forms There are others through WCF You choose an authentication.
Reset and Recycle IIS Reset Application Pool Management Error Codes New HTTP Sub-status codes Custom/Detailed Errors Tracing in IIS7 and.
Advanced ColdFusion: Error Handling Mosh Teitelbaum evoch, LLC.
Data Structures Using Java1 Chapter 2 Inheritance and Exception Handling.
Chapter 12 Handling Exceptions and Events. Chapter Objectives Learn what an exception is Become aware of the hierarchy of exception classes Learn about.
Exceptions cs1043. Program Exceptions When a program detects an error, what should it do? – Nothing, simply allow the program to fail. – Implement a course.
Model View Controller MVC Web Software Architecture.
This is the main tracing and diagnostics presentation. Very important that this be practical and useful information. IT Pro audience is very.
Sheet 3 HANDLING EXCEPTIONS Advanced Programming using Java By Nora Alaqeel.
Web Services Error Handling and Debugging. Agenda Simple SOAP faults Advanced SOAP faults SOAP headers and faults Error handling From a Service Perspective.
1 An Exception is… An unusual, often unpredictable event, detectable by software or hardware, that requires special processing An exception handler is.
ASP.NET User Controls. User Controls In addition to using Web server controls in your ASP.NET Web pages, you can create your own custom, reusable controls.
Chapter 15: Exception Handling C++ Programming: Program Design Including Data Structures, Fifth Edition.
Overview of Previous Lesson(s) Over View  ASP is a technology that enables scripts in web pages to be executed by an Internet server.  ASP.NET is a.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 14 Event-Driven Programming with Graphical User Interfaces.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
IMS 3253: Validation and Errors 1 Dr. Lawrence West, MIS Dept., University of Central Florida Topics Validation and Error Handling Validation.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
ASP.NET Programming with C# and SQL Server First Edition
ITEC 420 Framework Based Internet Applications
© 2016, Mike Murach & Associates, Inc.
Error Message Handling
Coding Defensively Coding Defensively
Handling Exceptions.
Chapter 14: Exception Handling
Exception Handling .NET MVC
Exceptions & Error Handling
Part B – Structured Exception Handling
Debugging and Handling Exceptions
Configuring .NET Web Applications
Created by Atif Aziz. ELMAH means is "Error Logging Modules and Handlers". It is an application-wide error logging facility that is completely pluggable.
ITEC 420 Framework Based Internet Applications
Presentation transcript:

Tracing, Logging, and Error Handling MacDonald Ch. 8 MIS 424 MIS 424 Professor Sandvig Professor Sandvig

Today  Error Handling Objective Objective IIS handlers IIS handlers.NET handlers.NET handlers Try Catch blockTry Catch block Exception Class Exception Class Page-level trappingPage-level trapping Application-level trappingApplication-level trapping Global.asax Global.asax Web.config Web.config

Error Handling  Goal: User NEVER sees yellow screen!! User NEVER sees yellow screen!! Handle errors gracefullyHandle errors gracefully Example: WWU, ThinkGeekExample: WWU, ThinkGeekWWUThinkGeekWWUThinkGeek  Implementation: 1. Robust programming Validate all user inputs Validate all user inputs Handle foreseeable problems Handle foreseeable problems 2. Trap all errors Handle gracefully Handle gracefully Error Pages Error Pages Log errors Log errors

Error Handling A good programmer is someone who always looks both ways before crossing a one-way street. Doug Linder systems administrator

Error Handling - IIS  Incorrect URLs may not reach.NET  Examples: 404 error handled by IIS 404 error handled by IIS 404 error 404 error 404 error handled by.NET 404 error handled by.NET 404 error 404 error  Request does not reach.NET  IIS has dozens of error pages May edit pages & routing rules May edit pages & routing rules

IIS

.NET  Request reaches.NET Extension:.aspx, asmx, etc. Extension:.aspx, asmx, etc.  Two options: Handle Programmatically Handle Programmatically web.config redirect web.config redirect

ASP.NET Error Handling Tools Catch errors at three levels: 1. Line: Try...Catch…Finally blocks 2. Page: Page_error() 3. Application: Global.asax

Line-level Error Handling  Try Catch Block  Wrap high-risk code Database, web services Database, web services All code that interacts with external data All code that interacts with external data  Benefits Provide handlers Provide handlers Graceful responseGraceful response Log errorLog error Continue code execution Continue code execution Easy to implement Easy to implement

Try Catch Block Syntax try{ // problematic code // problematic code} catch (Exception e) { // error handler code // error handler code}

Try Catch  Can trap by type of exception Trap specific first, then general Trap specific first, then general  Syntax: Catch objEx as FormatException { handler } Catch objEx as OleDbException { Handler } Catch objEx as Exception { Handler }

Exception Class  Exception object thrown when exception occurs  Contains info about problem  Two flavors: General (exception base class) General (exception base class)exception base classexception base class Specific (sqlException class) Specific (sqlException class)sqlException classsqlException class

Exception Class  Can also customize exceptions Provide specific information Provide specific information  Select appropriate exception and add custom message List of exceptions List of exceptions List of exceptions List of exceptions  Example: Dog class (from 324)

Exception Class  Set dog weight:

Try Catch Block  Where: Catch in.aspx page Catch in.aspx page Errors will bubble up Errors will bubble up Provide user with nice message Provide user with nice message Log error Log error

Exception Handling  Exceptions types Listed in MSDN documentation Listed in MSDN documentation System.Data.SqlClient SqlException ClassSystem.Data.SqlClient SqlException ClassSqlException ClassSqlException Class  Try Catch Example: source, output Example: source, outputsourceoutputsourceoutput WriteErrorLog.cs WriteErrorLog.cs WriteErrorLog.cs

Page Level error trapping  Catches unhandled exceptions on Page void Page_Error() { //handle error (write to log, redirect, etc.) //handle error (write to log, redirect, etc.)} Example: source, output Example: source, outputsourceoutputsourceoutput

Page_Error  Limitation Page execution is terminated Page execution is terminated Labels not displayed Labels not displayed User sees text error message User sees text error message Graceful response: Graceful response: Redirect user to an error pageRedirect user to an error page Better choice: Better choice: Handle at application levelHandle at application level

Application Level  Catches all unhandled exceptions Including 404s Including 404s  Examples: Amazon, Netflix AmazonNetflixAmazonNetflix  Two options: Global.asax Global.asax Web.Config file Web.Config file

Application Level  Global.asax  Handles application events Application start Application start Application end Application end Session start Session start Session end Session end Application_Error() Application_Error()  UnhandledError.aspx source, output sourceoutputsourceoutput

Application Level  Web.config Last in line Last in line  Redirects user to an error page  Syntax: </customErrors>

web.config  CustomErrors section  Redirect to error page  Can configure different pages for different error codes  Set on individual folders  Documentation: web.config web.config

Application Level  Web.config Disadvantage: cannot get error details for log Disadvantage: cannot get error details for log  Global.asax is better option Error details accessible Error details accessible

Summary  Error Trapping Objectives Objectives Handle exceptions gracefullyHandle exceptions gracefully Record details in log fileRecord details in log file 3 Levels 3 Levels 1.Line - Try Catch Block 2.Page - Page_Error() 3.Application Global.asax Application_Error Global.asax Application_Error web.config web.config