Name
GetLastError —
Set
objASPErr
= Server.GetLastError ()
Synopsis
The GetLastError method of the Server object allows you to display information about any error that occurs in your script. The GetLastError method returns a single ASPError object (see Chapter 5. You can use the returned ASPError object to display or programmatically respond to error information. The GetLastError method is new to ASP 3.0/IIS 5.0
Parameters
-
objASPErr
The name of the ASPError object returned by the GetLastError method.
Example
<% ' Instantiate an ASPError object using the GetLastError method of the ' Server object. Set objASPError = Server.GetLastError %> . . . HTML Display Etc. <% ' Use the properties of the ASPError object (returned by the GetLastError ' object) to display information about the error. ' *** FOR MORE INFORMATION, SEE THE ASPERROR OBJECT CHAPTER. Response.Write Server.HTMLEncode(objASPError.Category) If objASPError.ASPCode > "" Then Response.Write Server.HTMLEncode(", " & objASPError.ASPCode) End If Response.Write Server.HTMLEncode(" (0x" & Hex(objASPError.Number) & ")" ) & "<br>" If objASPError.ASPDescription > "" Then Response.Write Server.HTMLEncode(objASPError.ASPDescription) & "<br>" ElseIf (objASPError.Description > "") Then Response.Write Server.HTMLEncode(objASPError.Description) & "<br>" End if . . .
Notes
In this code example (derived from the default 500-100.ASP script that comes with IIS 5.0), the script begins by instantiating an ASPError object using the GetLast-Error method. ...
Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.