Chapter One fault-tolerant mechanism >

Source: Internet
Author: User
Tags end
Fault-tolerant first chapter fault-tolerant mechanism
In the case of the most popular ASP in China, I don't know how many people think of the concept of "fault tolerance" when they write code, actually, when I come across this kind of thing. Why, think about the original idea of thinking that writing code like this would be a fault-tolerant, as shown in example 1-1.

<%@ Language=vbscript%>

<%option explicit%>


' ERROR filtering

On Error Resume Next

............... (Code slightly)


Example 1-1 Common code glimpse

The above code often appears in the hands of fellow colleagues, needless to say the reason, I finished can understand you now mood, I can tell you frankly, I wrote two years of ASP page, most of this way, constantly write, constantly change, burnout, now do not want to go back to rewrite their own code. In fact, the idea of the most basic fault-tolerant mechanism is not to believe that the program can save you much, it is necessary to control the power in their own hands.

<%@ Language=vbscript%>

<%option explicit%>



DIM ndebug_msg


IF ndebug_msg = TRUE THEN

' ERROR filtering


End IF

' ===============end =====================

............... (Code slightly)

' Data transaction processing-start

If Err.Number = 0 Then

' ~~~~~ Open database and BEGIN TRANSACTION ~~~~~~~~~~~~~~~~~~~~




objConn.Execute (Objsql)

' ~~~~~~ Commit the transaction and close the database connection


Response.CacheControl = "Private"

Response.Expires =-1

............... (Code slightly)


' ~~~~~ Rollback transactions and close objects


' ~~~~~ Raise Errors for ASP page

' Err.Raise Err.Number, Err.Source, Err.Description

' Err.Clear

Response.Write "Description= (" & Err.Number & "), (" & Err. Description & ")"

End If

' ===============end files=====================


Example 1-2 complete fault-tolerant mechanism code example

Read the above code, you will find that there is no superb skills in the inside, the master may be dismissive. But you may not be able to do this when writing code.

"1-1" When writing dynamic Web pages, must consider fault-tolerant mechanism, such as in the ASP, you should refer to example 1-2, write robust code.

Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.