using System.Text;
using System.Web.Util;
using System.Web.Compilation;
+using System.Web.Management;
using System.Collections.Specialized;
namespace System.Web
{
const string DEFAULT_DESCRIPTION_TEXT = "Error processing request.";
const string ERROR_404_DESCRIPTION = "The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.";
-
+
+ int webEventCode = WebEventCodes.UndefinedEventCode;
int http_code = 500;
string resource_name;
string description;
const string errorStyleFonts = "\"Verdana\",\"DejaVu Sans\",sans-serif";
+
+#if NET_4_0
+ public
+#else
+ internal
+#endif
+ int WebEventCode
+ {
+ get { return webEventCode; }
+ }
public HttpException ()
{
: base (info, context)
{
http_code = info.GetInt32 ("_httpCode");
+ webEventCode = info.GetInt32 ("_webEventCode");
}
[SecurityPermission (SecurityAction.Demand, SerializationFormatter = true)]
{
base.GetObjectData (info, context);
info.AddValue ("_httpCode", http_code);
+ info.AddValue ("_webEventCode", webEventCode);
}
public HttpException (int httpCode, string message, int hr)
if (http_code != 404 && http_code != 403)
return GetCustomErrorDefaultMessage ();
else
- return GetDefaultErrorMessage (false);
+ return GetDefaultErrorMessage (false, null);
}
- if (!(this.InnerException is HtmlizedException))
- return GetDefaultErrorMessage (true);
+ Exception ex = GetBaseException ();
+ if (ex == null)
+ ex = this;
- return GetHtmlizedErrorMessage ();
+ HtmlizedException htmlException = ex as HtmlizedException;
+ if (htmlException == null)
+ return GetDefaultErrorMessage (true, ex);
+
+ return GetHtmlizedErrorMessage (htmlException);
} catch (Exception ex) {
Console.WriteLine (ex);
}
}
+ internal static HttpException NewWithCode (string message, int webEventCode)
+ {
+ var ret = new HttpException (message);
+ ret.SetWebEventCode (webEventCode);
+
+ return ret;
+ }
+
+ internal static HttpException NewWithCode (string message, Exception innerException, int webEventCode)
+ {
+ var ret = new HttpException (message, innerException);
+ ret.SetWebEventCode (webEventCode);
+
+ return ret;
+ }
+
+ internal static HttpException NewWithCode (int httpCode, string message, int webEventCode)
+ {
+ var ret = new HttpException (httpCode, message);
+ ret.SetWebEventCode (webEventCode);
+
+ return ret;
+ }
+
+ internal static HttpException NewWithCode (int httpCode, string message, Exception innerException, string resourceName, int webEventCode)
+ {
+ var ret = new HttpException (httpCode, message, innerException, resourceName);
+ ret.SetWebEventCode (webEventCode);
+
+ return ret;
+ }
+
+ internal static HttpException NewWithCode (int httpCode, string message, string resourceName, int webEventCode)
+ {
+ var ret = new HttpException (httpCode, message, resourceName);
+ ret.SetWebEventCode (webEventCode);
+
+ return ret;
+ }
+
+ internal static HttpException NewWithCode (int httpCode, string message, Exception innerException, int webEventCode)
+ {
+ var ret = new HttpException (httpCode, message, innerException);
+ ret.SetWebEventCode (webEventCode);
+
+ return ret;
+ }
+
+ internal void SetWebEventCode (int webEventCode)
+ {
+ this.webEventCode = webEventCode;
+ }
+
void WriteFileTop (StringBuilder builder, string title)
{
#if TARGET_J2EE
return builder.ToString ();
}
- string GetDefaultErrorMessage (bool showTrace)
+ string GetDefaultErrorMessage (bool showTrace, Exception baseEx)
{
- Exception ex, baseEx;
- ex = baseEx = GetBaseException ();
+ Exception ex;
+ ex = baseEx;
if (ex == null)
ex = this;
return filename;
}
- string GetHtmlizedErrorMessage ()
+ string GetHtmlizedErrorMessage (HtmlizedException exc)
{
StringBuilder builder = new StringBuilder ();
- HtmlizedException exc = (HtmlizedException) this.InnerException;
#if TARGET_J2EE
bool isParseException = false;
bool isCompileException = false;