コード例 #1
0
        /// <summary>
        /// Indexes the specified error code.
        /// </summary>
        /// <param name="code">The code.</param>
        /// <param name="minor">The minor.</param>
        /// <param name="message">The message.</param>
        /// <returns>ActionResult.</returns>
        public ActionResult Index(int? code = null, string minor = null, string message = null)
        {
            var exceptionInfo = new ExceptionInfo
            {
                Code = new ExceptionCode
                {
                    Major = ((ExceptionCode.MajorCode?)code) ?? ExceptionCode.MajorCode.Undefined,
                    Minor = minor
                },
                Message = message
            };

            return View(ErrorView, exceptionInfo);
        }
コード例 #2
0
        /// <summary>
        /// To the exception information.
        /// </summary>
        /// <param name="exception">The exception.</param>
        /// <param name="key">The key.</param>
        /// <param name="level">The level.</param>
        /// <returns>ExceptionInfo.</returns>
        private static ExceptionInfo ToExceptionInfo(Exception exception, Guid? key, ExceptionInfo.ExceptionCriticality level = ExceptionInfo.ExceptionCriticality.Error)
        {
            if (exception != null)
            {
                var baseException = exception as BaseException;
                if (key == null)
                {
                    key = baseException != null ? baseException.Key : Guid.NewGuid();
                }

                var operatorIdentifier = ContextHelper.CurrentCredential?.Key?.ToString();

                var exceptionInfo = new ExceptionInfo
                {
                    ExceptionType = exception.GetType()?.GetFullName(),
                    Level = level,
                    ServerIdentifier = EnvironmentCore.ServerName,
                    ServiceIdentifier = EnvironmentCore.ProjectName,
                    ServerHost = string.Format("{0} {1}", EnvironmentCore.LocalMachineHostName, EnvironmentCore.LocalMachineIpAddress),
                    Message = exception.Message,
                    Source = exception.Source,
                    TargetSite = exception.TargetSite.SafeToString(),
                    Code = baseException == null ? new ExceptionCode { Major = ExceptionCode.MajorCode.OperationFailure } : baseException.Code,
                    StackTrace = exception.StackTrace,
                    Data = baseException?.ReferenceData,
                    Key = key,
                    Scene = baseException?.Scene,
                    OperatorCredential = baseException?.OperatorCredential ?? (ContextHelper.CurrentCredential)
                };

                if (exception.InnerException != null)
                {
                    exceptionInfo.InnerException = ToExceptionInfo(exception.InnerException, key);
                }

                return exceptionInfo;
            }

            return null;
        }
コード例 #3
0
 /// <summary>
 /// To the exception information.
 /// </summary>
 /// <param name="exception">The exception.</param>
 /// <param name="level">The level.</param>
 /// <param name="operatorIdentifier">The operator identifier.</param>
 /// <returns>ExceptionInfo.</returns>
 public static ExceptionInfo ToExceptionInfo(this Exception exception, ExceptionInfo.ExceptionCriticality level = ExceptionInfo.ExceptionCriticality.Error, string operatorIdentifier = null)
 {
     return ToExceptionInfo(exception, null);
 }
コード例 #4
0
 /// <summary>
 /// Fills the exit information.
 /// </summary>
 /// <param name="exception">The exception.</param>
 /// <param name="exitStamp">The exit stamp.</param>
 internal void FillExitInfo(ExceptionInfo exception = null, DateTime? exitStamp = null)
 {
     this.ExitStamp = exitStamp ?? DateTime.UtcNow;
     this.Exception = exception;
 }
コード例 #5
0
 /// <summary>
 /// Fills the exit information.
 /// </summary>
 /// <param name="exception">The exception.</param>
 /// <param name="exitStamp">The exit stamp.</param>
 /// <param name="appIdentifier">The application identifier.</param>
 /// <param name="serverIdentifier">The server identifier.</param>
 /// <param name="level">The level.</param>
 /// <param name="operatorIdentifier">The operator identifier.</param>
 internal void FillExitInfo(BaseException exception = null, DateTime? exitStamp = null, string appIdentifier = null, string serverIdentifier = null, ExceptionInfo.ExceptionCriticality level = ExceptionInfo.ExceptionCriticality.Error, string operatorIdentifier = null)
 {
     this.ExitStamp = exitStamp ?? DateTime.UtcNow;
     this.Exception = exception.ToExceptionInfo(appIdentifier, serverIdentifier, level, operatorIdentifier);
 }