Esempio n. 1
0
        public static void Write(Exception e)
        {
            /* Skip if not in debug mode */
            if (!Config._.FKConfig.General.FKSettings.DebugMode)
            {
                return;
            }

            Instance.CreateDirectory(""); /* Create root FKError folder */

            bool   knownValue    = Enum.GetValues(typeof(ErrorTypes)).Cast <uint>().ToList().Contains((uint)e.HResult);
            string DirectorySlug = Instance.GetSlug("");
            int    eHash         = e.ToString().GetHashCode();

            if (knownValue)
            {
                ErrorTypes Error = (ErrorTypes)e.HResult;
                Instance.CreateDirectory(Error.ToString());
                DirectorySlug = Instance.GetSlug(Error.ToString());
            }

            string fileSlug = string.Format("{0}\\{1}.FKDump", DirectorySlug, eHash);

            if (!File.Exists(fileSlug))
            {
                using (StreamWriter fs = new StreamWriter(fileSlug))
                    fs.WriteLine(e);
            }
        }
Esempio n. 2
0
 static void DatabaseError(ErrorTypes error)
 {
     if (OnError != null)
     {
         OnError(error, error.ToString());
     }
     if (error == ErrorTypes.NotLogedIn) //if server has disconected you
     {
     }
     WriteLine($"Error: {error.ToString()}");
 }
Esempio n. 3
0
        public static SearchResponse <T> CreateFailedResponse <T>(this SearchResponse <T> response, ErrorTypes errorTypes, string message)
        {
            response = new SearchResponse <T>
            {
                Success = false,
                Message = message
            };
            response.Errors.AddError(errorTypes.ToString(), message);

            return(response);
        }
Esempio n. 4
0
        protected IActionResult LogAndReturnCustomError(ILogger logger, int code, ErrorTypes errorType, object objectID = null, [CallerMemberName] string methodName = null)
        {
            var ex = new ApplicationApiException(BackendLayersNames.API, errorType, new { Guid = Guid.NewGuid().ToString(), ID = objectID }, methodName: methodName);

            logger.LogError($"{ex.ErrorResponse.DeveloperMessage}");

            ex.ErrorResponse
            .SetError()
            .SetStatusCode(code)
            .SetUserMessage(this.SharedLocalizer.GetString(errorType.ToString()).Value);

            return(this.StatusCode(code, ex.ErrorResponse));
        }
Esempio n. 5
0
        /// <summary>
        /// Create a byte array containng an error object.
        /// </summary>
        /// <param name="error">The type of error.</param>
        /// <param name="detail">Additional detail related to the error.</param>
        /// <param name="data">Additional data related to the error.</param>
        /// <returns></returns>
        public static byte[] ToBytes(ErrorTypes error, string detail, object data)
        {
            Dictionary <string, object> outer = new Dictionary <string, object>();

            outer.Add("Success", false);

            Dictionary <string, object> inner = new Dictionary <string, object>();

            inner.Add("ErrorType", error.ToString());
            if (!String.IsNullOrEmpty(detail))
            {
                inner.Add("ErrorDetail", detail);
            }
            if (data != null)
            {
                inner.Add("Data", data);
            }

            outer.Add("Error", inner);
            return(Encoding.UTF8.GetBytes(Common.SerializeJson(outer)));
        }
Esempio n. 6
0
        //   [Conditional("DEBUG")]
        private void ProcessError(ErrorTypes nErrorType, string strCmd)
        {
            string str = "Command decode error !Command: " + Message.ToString("X2") + " [Error Code]:" + nErrorType.ToString() + " [Error Cmd]:" + strCmd;

            //  System.Windows.Forms.MessageBox.Show(str);
            log4net.ILog log = log4net.LogManager.GetLogger("MyLogger");
            log.Debug(str);
        }
 public OutputCommand(ErrorTypes eError)
 {
     type = "err";
     data = eError.ToString("d");
 }
Esempio n. 8
0
        private void ErrorResolution(Site site, int statuscode, ErrorTypes errorType)
        {
            if (_restartCodes.Contains(statuscode) && (site.FailureCount < 4 || site.FailureCount % 10 == 0))
            {
                // only notify after 15 minutes
                if (site.FailureCount == 3)
                {
                    // trigger an email about a failed site
                    Console.WriteLine("Admin Intervene ({0}) with error {1}. Failure count {2}", site.Url, errorType.ToString(), site.FailureCount);
                }
                // only attempt a restart for the first few times
                else
                {
                    // try to restart the application pool
                    Console.WriteLine("Attempting restart ({0}).  Failure count {1}", site.Url, site.FailureCount);

                    RestartApplicationPool(site.AppPool);
                }
            }
        }
        //  [Conditional("DEBUG")]
        protected void ProcessError(CBase command, ErrorTypes nErrorType)
        {
            string str = "Error has occurred in USB operation duration !Command: " + command.Message.ToString("X2") + " [Error Code]:" + nErrorType.ToString();

            //  System.Windows.Forms.MessageBox.Show(str);
            log4net.ILog log = log4net.LogManager.GetLogger("MyLogger");
            log.Debug(str);
        }
Esempio n. 10
0
 public string GetErrorMessage(ErrorTypes types)
 {
     return(types.ToString());
 }
Esempio n. 11
0
 protected BaseException(string message, ErrorTypes errorTypes, Exception ex)
     : base(message, ex)
 {
     ErrorCode = (int)errorTypes;
     ErrorType = errorTypes.ToString();
 }