Esempio n. 1
0
 public HandleErrorModel(Exception exception)
 {
     Core.BaseException _baseEx = null;
     if (exception is Core.BaseException)
     {
         _baseEx = exception as Core.BaseException;
     }
     else
     {
         _baseEx = new Core.BaseException(Core.BaseException.DefaultErrorNumber, exception.Message, exception);
     }
     ErrorID      = _baseEx.ErrorID;
     ErrorNumber  = _baseEx.ErrorNumber;
     ErrorMessage = _baseEx.Message;
     if (MVC.ExceptionHandling.ErrorHandlerAttribute.ShowActualError)
     {
         Exception _innerEx = _baseEx;
         while (_innerEx.InnerException != null)
         {
             _innerEx = _innerEx.InnerException;
         }
         ErrorTrace = _innerEx.StackTrace;
     }
     else
     {
         ErrorTrace = string.Empty;
     }
 }
Esempio n. 2
0
 void ILogManager.Error(Exception ex)
 {
     if (ex == null)
     {
         return;
     }
     if (_log.IsErrorEnabled)
     {
         try
         {
             string _errorMsg = string.Format("Number: {0}", Core.BaseException.DefaultErrorNumber);
             if (ex is Core.BaseException)
             {
                 Core.BaseException _coreEx = (ex as Core.BaseException);
                 if (_coreEx.IsLogged)
                 {
                     return;
                 }
                 _errorMsg = string.Format("ID: {0} | Number: {1}", _coreEx.ErrorID, _coreEx.ErrorNumber);
             }
             Exception _innerEx = ex;
             while (true)
             {
                 if (_innerEx.InnerException == null)
                 {
                     break;
                 }
                 _innerEx = _innerEx.InnerException;
             }
             _errorMsg = _errorMsg + " | Message: " + ex.Message + " Trace: " + (_innerEx != null ? _innerEx.StackTrace : ex.StackTrace);
             _log.Error(_errorMsg);
         }
         catch { }
     }
 }
Esempio n. 3
0
        private void Context_Error(object sender, EventArgs e)
        {
            HttpApplication _appObject = sender as HttpApplication;

            if (_appObject != null)
            {
                Exception _exception = _appObject.Server.GetLastError();
                if (_exception == null)
                {
                    return;
                }
                _appObject.Server.ClearError();

                Core.BaseException _coreEx = null;
                if (_exception is Core.BaseException)
                {
                    _coreEx = (Core.BaseException)_exception;
                }
                else
                {
                    _coreEx = new Core.BaseException(Utilities.DefaultErrorNumber, _exception.Message, _exception);
                }
                string _errorNumber = _coreEx.ErrorNumber;
                string _errorID     = _coreEx.ErrorID;

                Utilities.LogManager.Error(_coreEx);

                if (Utilities.IsAjaxRequest)
                {
                    var _jsonSerializer = new JavaScriptSerializer();
                    var _json           = _jsonSerializer.Serialize(new HandleErrorModel(_coreEx));

                    _appObject.Response.Clear();
                    _appObject.Response.ContentType = Utilities.JsonContentType;
                    _appObject.Response.Write(_json);

                    _jsonSerializer = null;
                }
                else
                {
                    _appObject.Response.Redirect(string.Format("/{0}/{1}?ErrorID={2}&ErrorNumber={3}", ErrorHandlerAttribute.ErrorContoller, ErrorHandlerAttribute.ErrorGeneralView,
                                                               _errorID, _errorNumber));
                }
            }
        }
 public ActionResult Error()
 {
     Core.BaseException ex = new Core.BaseException();
     return(View(ex));
 }