Error Handling - E-Commerce - Lecture Slides, Slides of Fundamentals of E-Commerce

Students of Communication, study E-Commerce as an auxiliary subject. these are the key points discussed in these Lecture Slides of E-Commerce : Error Handling, Active Server Pages, Web Programming, Negative Browsing, Experience, Handle Errors, Page Causes, Trap Executes, Error Handling Causes, Implemented Error

Typology: Slides

2012/2013

Uploaded on 07/29/2013

sharad_984
sharad_984 🇮🇳

4.5

(13)

129 documents

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Server-Side Web Programming
with Active Server Pages
ASP Error Handling
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Error Handling - E-Commerce - Lecture Slides and more Slides Fundamentals of E-Commerce in PDF only on Docsity!

Server-Side Web Programming

with Active Server Pages

ASP Error Handling

Introduction

•^

The purpose of error handling is to prevent the user fromhaving a negative browsing experience on your site.

-^

The best way to handle errors on the web is to avoid them.

-^

Error handling in ASP carries with it some performancepenalties^ –

Any error handling on a page causes overhead– Each statement within an error trap executes more slowly– Poorly implemented error handling causes progressive problemsand can cause your entire web application to fail.– Worse, poorly implemented error handling can cause businesslogic to execute (or not) that has unfortunate consequences for thedata integrity of your site.

The ERR Object

-^

vbScript and VB 4.x and higher provide acentralized error object.

-^

It has some useful Properties and Methods^ –.

Number

= Error Number (Default Property) Zero

means no Error.

-.

Description

= Text Narrative of Error (Property) This

changes to be specific for this error instance.

-.

Clear

--> Method to clear error

RaiseError

--> Method to generate your own run time

errors.

Setting an error trap

• On Error Resume Next

  • Sets an error trap– Instead of errors being “un-handled” thus

shown to the end user either as the error textitself or as a 5xx “Server Error”, the Err Objectis populated and can be tested.

• On Error Goto 0

  • Turn off error handling.– Always do this as soon as possible

How to handle errors

-^

Prevent errors that can be anticipated–

Code defensively– Most errors in VbScript can be avoided

-^

Handle known errors that can not be prevented^ –

429 “Cannot create object”

-^

Various ADO errors.

-^

Design Goal: Make each task transactional and atomic^ –

Have an error handler in the topmost event

-^

Know where the app should be in case of error

-^

Raising Errors is not a good technique for “vanilla” ASP.^ –

Really that technique is designed for pages running in an MTS contextand is out side the scope of this class.

Preventing Errors

Function Divide(X, Y)

Dim dRetdRet =

If Y <> 0 then

dRet = X / Y

End ifDivide

= dRet

Exit Function End Function

Problem:

Divide by zero

is evil. Solution:

Check for a

problem beforecalculating. Give a safenon-answer. Practice:

Good.

Philosophy

• Fail Safe

  • Be as resilient as possible– Recover from error– Put user in state where they can continue work – Makes knowing there is an error harder to spot

• Fail Fast

  • Clean up and exit as soon as possible– Makes spotting errors easier (good when developing) – Makes a big disaster out of small errors

Error Handling Tips

•^

Be careful that you do not use error handling as a substitutefor^ –

Good Coding.– Failure to Trap and Avoid Bad Data.– Common Sense.

-^

Use only where you MUST!^ –

Creating non-intrinsic objects using CreateObject()– External Methods (Such as sending an e-mail)

-^

Always CLEAR your errors as soon as possible

-^

Never leave an open error trap across scope levels in ASP.E.g. make sure you clear your error trap before returningfrom a function or sub