Esempio n. 1
0
        private void lbErrorList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (lbErrorList.SelectedItem != null)
            {
                ListBoxItem     selectedItem = (ListBoxItem)lbErrorList.SelectedItem;
                ErrorDescriptor error        = (ErrorDescriptor)selectedItem.Tag;
                tbCode.ScrollTo(error.Line, error.Position);

                if (error.HasExactPosition)
                {
                    try
                    {
                        tbCode.Select(error.StartPosition, error.EndPosition - error.StartPosition + 1);
                    }
                    catch (ArgumentOutOfRangeException) { }
                }
                else
                {
                    try
                    {
                        tbCode.Select(GetFirstIndexInLine(tbCode, error.Line - 1) + error.Position, 1);
                    }
                    catch (ArgumentOutOfRangeException) { }
                }

                lbErrorList.SelectedItem = null;
            }
        }
Esempio n. 2
0
 internal IdentityError Error(ErrorDescriptor descriptor, params object[] args)
 {
     return(new IdentityError
     {
         Code = descriptor.ToString(),
         Description = _localizer.GetString(descriptor, args)
     });
 }
Esempio n. 3
0
                static MemoryStream JsonSerialize(ErrorDescriptor error)
                {
                    var bytes = JsonSerializer.SerializeToUtf8Bytes(
                        new ErrorResponse(error),
                        new JsonSerializerOptions
                    {
                        PropertyNamingPolicy   = JsonNamingPolicy.CamelCase,
                        DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
                    });

                    return(new MemoryStream(bytes));
                }
        /// <summary>
        /// Adds the error to error list.
        /// </summary>
        /// <param name="MethodName">Name of the method.</param>
        /// <param name="ExeptionMessage">The exeption message.</param>
        public void AddErrorToErrorList(string MethodName, string ExeptionMessage)
        {
            ErrorDescriptor errordescriptor = new ErrorDescriptor();

            errordescriptor.MethodName      = MethodName;
            errordescriptor.ExeptionMessage = ExeptionMessage;
            errordescriptor.DateOfError     = DateTime.Now;
            //lock(ErrorList)
            //{
            ErrorList.Add(errordescriptor);
            //}
            sueDB.AddErrorToDB(errordescriptor);
        }
Esempio n. 5
0
                static async Task <MemoryStream> XmlSerializeAsync(ErrorDescriptor error)
                {
                    var stream = new MemoryStream();

                    await using var writer = XmlWriter.Create(
                                    stream,
                                    new XmlWriterSettings
                    {
                        Async    = true,
                        Encoding = new UTF8Encoding(false)
                    });
                    await new ErrorResponse(error).WriteXmlContentsAsync(writer).ConfigureAwait(false);
                    return(stream);
                }
 public string GetErrorMessage(ErrorDescriptor error, CultureInfo culture)
 {
     return(error.Key);
 }
Esempio n. 7
0
 static async Task <HttpResponseData> CreateHttpResponseData(HttpRequestData request, HttpStatusCode httpStatusCode, ErrorDescriptor error)
 {
Esempio n. 8
0
        /// <summary>
        /// 获取安全错误。
        /// </summary>
        /// <param name="describer">错误描述实例。</param>
        /// <param name="errorDescriptor">错误枚举实例。</param>
        /// <param name="args">参数。</param>
        /// <returns>返回错误实例。</returns>
        public static IdentityError SecurityError(this IdentityErrorDescriber describer, ErrorDescriptor errorDescriptor, params object[] args)
        {
            if (describer is SecurityErrorDescriptor descriptor)
            {
                return(descriptor.Error(errorDescriptor, args));
            }

            return(describer.DefaultError());
        }
Esempio n. 9
0
 private static string GetMessageByErrorDescriptor(ErrorDescriptor errorDescriptor)
 {
     return(String.Format("{0}{1}{2}", errorDescriptor.Title,
                          Environment.NewLine,
                          string.Join(Environment.NewLine, errorDescriptor.Items.Select(i => i.UserMessage))));
 }
Esempio n. 10
0
 public ServerException(ErrorDescriptor errorDescriptor) : this(GetMessageByErrorDescriptor(errorDescriptor))
 {
     _errorDescriptor = errorDescriptor;
 }
Esempio n. 11
0
 public static ResultInfo Fail(ErrorType errorType, string message) => new ResultInfo(false, ErrorDescriptor.Create(errorType, message));
Esempio n. 12
0
 private ResultInfo(bool isOk, ErrorDescriptor error)
 {
     IsOk  = isOk;
     Error = error;
 }
Esempio n. 13
0
 private IdentityError Error(IdentityError error, ErrorDescriptor descriptor, params object[] args)
 {
     error.Description = _localizer.GetString(descriptor, args);
     return(error);
 }
Esempio n. 14
0
 public BusinessException(ErrorDescriptor descriptor)
 {
     Descriptor = descriptor;
 }
Esempio n. 15
0
 private void LogResultError(string url, TransactionErrorCodes?err)
 {
     var errorDescriptor = new ErrorDescriptor();
     //Logger.Error("Error from {url}: {error}", url, errorDescriptor.GetErrorInfo(err));
 }