ASP 三层架构 Error处理类(2)


e.BR 输出一个换行符,等同于 response.Write "<BR />"
以下4个是对Response.End的包装,只是按照操作习惯,定义的几个一样功能的方法:
e.Pause == Response.End
e.P == Response.End
e.Stop == Response.End
e.End == Response.End
还有一个属性e.Message ,输出e对象中所有的错误列表
具体的实现细节请看代码
复制代码 代码如下:

Class Con_Error
Private blnError
private strMessage
private strJSMessage
Private Sub Class_initialize()
blnError = false
strMessage = ""
End Sub
Private Sub Class_Terminate()
End Sub
' ==================================================================================
' Property
' ==================================================================================
' Message :
Public Property Let Message(ByVal value)
strMessage = value
End Property
Public Property Get Message()
Message = strMessage
End Property
' Error number
Public Property Get Error()
Error = blnError
End Property
' JSMessage : show in messagebox
Private Property Get JSMessage()
strJSMessage = Replace(strMessage , "<br>" , "\n")
strJSMessage = Replace(strJSMessage , vbCrLf , "")
JSMessage = strJSMessage
End Property
' ==================================================================================
' Method
' ==================================================================================
' Add : add an Error message
Public Sub Add(ByVal vMessage)
blnError = true
strMessage = strMessage & vMessage & "<br>"
End Sub
Public Sub Clear
blnError = false
strMessage = ""
End Sub
' Alert
Public Sub Alert(ByVal vMessage)
strJSMessage = JSMessage & vMessage
%>
<script language="javascript" >
<!--//
alert("<%=strJSMessage %>");
//-->
</script>
<%
End Sub
' Alert_Back : alert and back
Public Sub Alert_Back(ByVal vMessage)
strJSMessage = JSMessage & vMessage
%>
<script language="javascript" >
<!--//
alert("<%=strJSMessage %>");
history.back();
//-->
</script>
<%
response.end
End Sub
' Alert_Close : alert and close
Public Sub Alert_Close(ByVal vMessage)
strJSMessage = JSMessage & vMessage
%>
<script language="javascript" >
<!--//
alert("<%=strJSMessage %>");
window.opener = null;
window.close();
//-->
</script>
<%
response.end
End Sub
'*********************************************
'Debug : response.write ,use it to delete debug message easily,just seach "e.Debug" from files
'*********************************************
Public Sub OK_Go(ByVal vMessage,ByVal vURL)
strJSMessage = JSMessage & vMessage
%>
<script language="javascript" >

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/2041.html