示例#1
0
        public static ExceptionReport buildreport(Exception e)
        {
            ExceptionReport exceptionreport = new ExceptionReport ();

            if (e is WebException) {
                WebException ex = e as WebException;
                exceptionreport.errorclass = ErrorClass.Error;
                exceptionreport.errortype = ErrorType.Error;
                if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null) {
                    var resp = (HttpWebResponse)ex.Response;
                    var status = ex.Status;
                    switch (resp.StatusCode) {
                    case HttpStatusCode.BadRequest:
                        exceptionreport.errortype = ErrorType.BadRequest;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.Unauthorized:
                        exceptionreport.errortype = ErrorType.Unauthorized;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.PaymentRequired:
                        exceptionreport.errortype = ErrorType.PaymentRequired;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.Forbidden:
                        exceptionreport.errortype = ErrorType.Forbidden;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.NotFound:
                        exceptionreport.errortype = ErrorType.NotFound;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.MethodNotAllowed:
                        exceptionreport.errortype = ErrorType.MethodNotAllowed;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.NotAcceptable:
                        exceptionreport.errortype = ErrorType.NotAcceptable;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.ProxyAuthenticationRequired:
                        exceptionreport.errortype = ErrorType.ProxyAuthenticationRequired;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.RequestTimeout:
                        exceptionreport.errortype = ErrorType.RequestTimeout;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.Conflict:
                        exceptionreport.errortype = ErrorType.Conflict;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.Gone:
                        exceptionreport.errortype = ErrorType.Gone;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.LengthRequired:
                        exceptionreport.errortype = ErrorType.LengthRequired;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.PreconditionFailed:
                        exceptionreport.errortype = ErrorType.PreconditionFailed;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.RequestEntityTooLarge:
                        exceptionreport.errortype = ErrorType.RequestEntityTooLarge;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.RequestUriTooLong:
                        exceptionreport.errortype = ErrorType.RequestUriTooLong;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.UnsupportedMediaType:
                        exceptionreport.errortype = ErrorType.UnsupportedMediaType;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.RequestedRangeNotSatisfiable:
                        exceptionreport.errortype = ErrorType.RequestedRangeNotSatisfiable;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.ExpectationFailed:
                        exceptionreport.errortype = ErrorType.ExpectationFailed;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.UpgradeRequired:
                        exceptionreport.errortype = ErrorType.UpgradeRequired;
                        exceptionreport.errorclass = ErrorClass.InternetClientError;
                        break;
                    case HttpStatusCode.InternalServerError:
                        exceptionreport.errortype = ErrorType.InternalServerError;
                        exceptionreport.errorclass = ErrorClass.InternetServerError;
                        break;
                    case HttpStatusCode.NotImplemented:
                        exceptionreport.errortype = ErrorType.NotImplemented;
                        exceptionreport.errorclass = ErrorClass.InternetServerError;
                        break;
                    case HttpStatusCode.BadGateway:
                        exceptionreport.errortype = ErrorType.BadGateway;
                        exceptionreport.errorclass = ErrorClass.InternetServerError;
                        break;
                    case HttpStatusCode.ServiceUnavailable:
                        exceptionreport.errortype = ErrorType.ServiceUnavailable;
                        exceptionreport.errorclass = ErrorClass.InternetServerError;
                        break;
                    case HttpStatusCode.GatewayTimeout:
                        exceptionreport.errortype = ErrorType.GatewayTimeout;
                        exceptionreport.errorclass = ErrorClass.InternetServerError;
                        break;
                    case HttpStatusCode.HttpVersionNotSupported:
                        exceptionreport.errortype = ErrorType.HttpVersionNotSupported;
                        exceptionreport.errorclass = ErrorClass.InternetServerError;
                        break;
                    }
                }
                else if(ex.Status == WebExceptionStatus.ProtocolError && ex.Response == null){
                    exceptionreport.errortype = ErrorType.ProtocolError;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.NameResolutionFailure){
                    exceptionreport.errortype = ErrorType.NameResolutionFailure;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.ConnectFailure){
                    exceptionreport.errortype = ErrorType.ConnectFailure;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.ReceiveFailure){
                    exceptionreport.errortype = ErrorType.ReceiveFailure;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.SendFailure){
                    exceptionreport.errortype = ErrorType.SendFailure;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.PipelineFailure){
                    exceptionreport.errortype = ErrorType.PipelineFailure;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.RequestCanceled){
                    exceptionreport.errortype = ErrorType.RequestCanceled;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.ProtocolError){
                    exceptionreport.errortype = ErrorType.ProtocolError;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.ConnectionClosed){
                    exceptionreport.errortype = ErrorType.ConnectionClosed;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.TrustFailure){
                    exceptionreport.errortype = ErrorType.TrustFailure;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.SecureChannelFailure){
                    exceptionreport.errortype = ErrorType.SecureChannelFailure;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.ServerProtocolViolation){
                    exceptionreport.errortype = ErrorType.ServerProtocolViolation;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.KeepAliveFailure){
                    exceptionreport.errortype = ErrorType.KeepAliveFailure;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.Pending){
                    exceptionreport.errortype = ErrorType.Pending;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.Timeout){
                    exceptionreport.errortype = ErrorType.Timeout;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.ProxyNameResolutionFailure){
                    exceptionreport.errortype = ErrorType.ProxyNameResolutionFailure;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.UnknownError){
                    exceptionreport.errortype = ErrorType.UnknownError;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.MessageLengthLimitExceeded){
                    exceptionreport.errortype = ErrorType.MessageLengthLimitExceeded;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.CacheEntryNotFound){
                    exceptionreport.errortype = ErrorType.CacheEntryNotFound;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.RequestProhibitedByCachePolicy){
                    exceptionreport.errortype = ErrorType.RequestProhibitedByCachePolicy;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                else if(ex.Status == WebExceptionStatus.RequestProhibitedByProxy){
                    exceptionreport.errortype = ErrorType.RequestProhibitedByProxy;
                    exceptionreport.errorclass = ErrorClass.InternetError;
                }
                exceptionreport.errormessage = exceptionreport.errorclass.ToString () +":"+exceptionreport.errortype.ToString ();
            }
            else{
                exceptionreport.errorclass = ErrorClass.Error;
                exceptionreport.errortype = ErrorType.Error;
                exceptionreport.errormessage =  ErrorClass.Error.ToString()+":"+e.GetType().Name;
            }
            return exceptionreport;
        }
示例#2
0
 public LoadContentThread(Tap5050WebRequest webrequest, MsgHandler responsehander)
 {
     nn_webrequest = webrequest;
     nn_responsehander = responsehander;
     exceptionreport = new ExceptionReport();
 }