• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# System.Error类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Error的典型用法代码示例。如果您正苦于以下问题:C# Error类的具体用法?C# Error怎么用?C# Error使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Error类属于System命名空间,在下文中一共展示了Error类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: EqualsWithDifferentFiles

		[Test] public void EqualsWithDifferentFiles()
		{
			Error E1 = new Error(File1, "Error");
			Error E2 = new Error(File2, "Error");

			Assert.IsFalse(E1.Equals(E2), "Error.Equals does not return false for errors with differing files");
		}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:ErrorTestCase.cs


示例2: SendMail

        /// <summary>
        /// If enabled, sends an error email to the configured recipients
        /// </summary>
        /// <param name="error">The error the email is about</param>
        public static void SendMail(Error error)
        {
            if (!Enabled) return;
            // The following prevents errors that have already been stored from being emailed a second time.
            if (PreventDuplicates && error.IsDuplicate) return;
            try
            {

                using (var message = new MailMessage())
                {
                    message.To.Add(ToAddress);
                    if (FromAddress != null) message.From = FromAddress;

                    message.Subject = ErrorStore.ApplicationName + " error: " + error.Message.Replace(Environment.NewLine, " ");
                    message.Body = GetErrorHtml(error);
                    message.IsBodyHtml = true;

                    using (var client = GetClient())
                    {
                        client.Send(message);
                    }
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
            }
        }
开发者ID:ActivePHOENiX,项目名称:StackExchange.Exceptional,代码行数:32,代码来源:ErrorEmailer.cs


示例3: SendMail

        /// <summary>
        /// If enabled, sends an error email to the configured recipients
        /// </summary>
        /// <param name="error">The error the email is about</param>
        public static void SendMail(Error error)
        {
            if (!Enabled) return;
            try
            {

                using (var message = new MailMessage())
                {
                    message.To.Add(ToAddress);
                    if (FromAddress != null) message.From = FromAddress;

                    message.Subject = ErrorStore.ApplicationName + " error: " + error.Message;
                    message.Body = GetErrorHtml(error);
                    message.IsBodyHtml = true;

                    using (var client = GetClient())
                    {
                        client.Send(message);
                    }
                }
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
            }
        }
开发者ID:stanroze,项目名称:StackExchange.Exceptional,代码行数:30,代码来源:ErrorEmailer.cs


示例4: CanGetError

        public void CanGetError()
        {
            // Arrange
            var fixture = new Fixture();
            const string id = "mock error id";
            var applicationName = fixture.Create<string>();

            var error = new Error(new HttpException());
            var errorXml = ErrorXml.EncodeString(error);

            var mockResponse = new Mock<IGetResponse<ErrorDocument>>();
            mockResponse.Setup(x => x.Source).Returns(new ErrorDocument { ErrorXml = errorXml });
            mockResponse.Setup(x => x.IsValid).Returns(true);

            var elasticClientMock = new Mock<IElasticClient>();
            elasticClientMock
                .Setup(x => x.Get(It.IsAny<Func<GetDescriptor<ErrorDocument>, GetDescriptor<ErrorDocument>>>()))
                .Returns(mockResponse.Object);

            var errorLog = new ElasticSearchErrorLog(elasticClientMock.Object, new Hashtable())
            {
                ApplicationName = applicationName,
            };

            // Act
            var elmahError = errorLog.GetError(id);

            // Assert
            Assert.That(elmahError != null);
            Assert.That(elmahError.Id, Is.EqualTo(id));
            Assert.That(elmahError.Error != null);
            Assert.That(elmahError.Error.ApplicationName, Is.EqualTo(applicationName));
        }
开发者ID:360imprimir,项目名称:Elmah.Io.ElasticSearch,代码行数:33,代码来源:ElasticSearchErrorLogTest.cs


示例5: ErrorMailHtmlPage

 public ErrorMailHtmlPage(Error error, ErrorMailOptions options = null)
 {
     Error = error;
     if (error.Exception != null)
         ErrorLogEntry = LoggedException.RecallErrorLogEntry(error.Exception);
     Options = options ?? DefaultOptions;
 }
开发者ID:elmah,项目名称:Fabmail,代码行数:7,代码来源:ErrorMailHtmlPage.cs


示例6: ContainsWord

		/// <summary>
		/// Dictionary contains the word.
		/// </summary>
		public bool ContainsWord(string word, Lang lang, out Error error)
		{
			lock (_sync)
			{
				error = null;
				if (_externalDictionary.ContainWord(word, lang))
					return true;

				SpellResult result = _yandexSpeller.CheckText(word, lang, Options.ByWords, TextFormat.Plain);
				if (result.Errors.Count > 0)
				{
					error = result.Errors[0];
					return false;
				}

				_innerUpdate = true;

				try
				{
					_externalDictionary.AddWord(word, lang);
				}
				finally
				{
					_innerUpdate = false;
				}


				return true;
			}
		}
开发者ID:gmalyshev,项目名称:Yandex.Speller.VS-extension,代码行数:33,代码来源:YandexDictionary.cs


示例7: Run

        public void Run()
        {
            Console.WriteLine("Press 'Enter' to send a message. To exit, Ctrl + C");

            while (true)
            {
                var read = Console.ReadLine();
                LogMessage message = null;
                read = string.IsNullOrEmpty(read) ? "info Info Message" : read;

                if (read.IndexOf(" ") < 0)
                    read += " Log Message";

                var type = read.Substring(0, read.IndexOf(" "));
                var payload = read.Substring(read.IndexOf(" ") + 1);

                switch (type.ToLower())
                {
                    case "warn":
                        message = new Warn();
                        break;
                    case "error":
                        message = new Error();
                        break;
                    default:
                        message = new Info();
                        break;
                }

                message.Message = payload;
                Bus.Send(message);
            }
        }
开发者ID:jonocairns,项目名称:nservicebusrabbitmq,代码行数:33,代码来源:Bootstrap.cs


示例8: recibeMensajeBErr

        public static IList recibeMensajeBErr(byte[] byteRec)
        {
            Array.Resize(ref byteRec, 169);

            PRN prn = new PRN();
            Error err = new Error();

            //codPaquete = Conversiones.AgregaCadena(byteRec, 0, 1);// Cod. de Paquete
            err.CodError = (UInt16)Conversiones.AgregaDigito16(byteRec, 1);// Cod. de ERROR
            //flagLongFile = (byte)Conversiones.AgregaDigito(byteRec, 3, 1);// FLag LongFile
            //longFile = (UInt32)Conversiones.AgregaDigito32(byteRec, 4, 4);// LongFile
            //correo = (byte)Conversiones.AgregaDigito(byteRec, 8, 1);// Correo

            prn.Nombre1 = Conversiones.AgregaCadena(byteRec, 9, 10); //  Usuario 0
            prn.Nombre2 = Conversiones.AgregaCadena(byteRec, 19, 10); // Usuario 1
            prn.Nombre3 = Conversiones.AgregaCadena(byteRec, 29, 10); // Usuario 2

            prn.Port1 = Conversiones.AgregaCadena(byteRec, 39, 15); // Direccion 0 //DUDA: string o int?
            prn.Port2 = Conversiones.AgregaCadena(byteRec, 54, 15); // Direccion 1 //DUDA: string o int?
            prn.Port3 = Conversiones.AgregaCadena(byteRec, 69, 15); // Direccion 2 //DUDA: string o int?

            prn.Telefono1 = Conversiones.AgregaCadena(byteRec, 84, 15); // Telefono 0
            prn.Telefono2 = Conversiones.AgregaCadena(byteRec, 99, 15); // Telefono 1
            prn.Telefono3 = Conversiones.AgregaCadena(byteRec, 114, 15); // Telefono 2

            err.Descripcion = Conversiones.AgregaCadena(byteRec, 129, 40); // Mensaje de ERROR

            IList menB = new List<object> { err, prn };
            return menB;
        }
开发者ID:gabalesev,项目名称:modulocom,代码行数:30,代码来源:ConstructorMenRec.cs


示例9: ErroneousTrack

 public ErroneousTrack(ISession session, IntPtr handle, Error error, IPlaylist playlist = null)
     : base(session, handle)
 {
     _error = error;
     _playlist = playlist;
     _artists = new DelegateArray<IArtist>(() => 0, index => null);
 }
开发者ID:sekotin,项目名称:torshify,代码行数:7,代码来源:ErroneousTrack.cs


示例10: TestCookie

        public void TestCookie()
        {
            const string CookieName = "ASP.NET_SessionId";

            var configurationSection = new MaskedValuesConfigurationSection();
            configurationSection.RemoveAspxAuth = false;
            configurationSection.ReplacementText = "OBSCURED";
            configurationSection.Cookies.Add(new MaskedItemElement(CookieName));

            using (HttpSimulator simulator = new HttpSimulator("/", @"c:\inetpub\"))
            {
                simulator.SetCookies(Cookies)
                         .SimulateRequest(new Uri("http://localhost/"));

                var error = new Error(new HttpRequestValidationException(), HttpContext.Current);

                Assert.IsNotNull(HttpContext.Current.Request.Cookies[CookieName]);

                ErrorHelper.Obscure(error, configurationSection);

                Assert.AreEqual(configurationSection.ReplacementText, error.Cookies[CookieName]);

                Assert.AreNotEqual(configurationSection.ReplacementText, error.Cookies[MaskedValuesConfigurationSection.AspxAuthCookie]);
            }
        }
开发者ID:paultew,项目名称:Elmah.DataProtection,代码行数:25,代码来源:ErrorObscureTests.cs


示例11: TestDeepEquals

 private void TestDeepEquals(Error objectA, Error objectB, bool expect, bool expectDeep)
 {
     Assert.AreEqual(expectDeep, objectA.DeepEquals(objectB));
     Assert.AreEqual(expectDeep, objectB.DeepEquals(objectA));
     Assert.AreEqual(expect, objectA.Equals(objectB));
     Assert.AreEqual(expect, objectB.Equals(objectA));
 }
开发者ID:electromute,项目名称:gnip-dotnet,代码行数:7,代码来源:ErrorTest.cs


示例12: FromException

        public static ErrorResponse FromException(Exception exception)
        {
            //var exception = ex.GetRootError();

            var summary = exception.Message;
            if (exception is WebException || exception is SocketException)
                summary = "";

            var statusCode = HttpStatusCode.InternalServerError;
            var error = new Error();
            if (exception is LightstoneAutoException)
            {
                statusCode = HttpStatusCode.InternalServerError;
                error.ErrorMessage = summary;
            }
            else if (exception is NotImplementedException)
                statusCode = HttpStatusCode.NotImplemented;
            else if (exception is UnauthorizedAccessException)
            {
                statusCode = HttpStatusCode.Forbidden;
                error.ErrorMessage = "Sorry, you do not have permission to perform that action. Please contact Lightstone Auto.";
            }
            else if (exception is AuthenticationException)
                statusCode = HttpStatusCode.Unauthorized;
            else if (exception is ArgumentException)
                statusCode = HttpStatusCode.BadRequest;

            return new ErrorResponse(error) { StatusCode = statusCode };
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:29,代码来源:ErrorResponse.cs


示例13: Equals

		[Test] public void Equals()
		{
			Error E1 = new Error(File1, "Error");
			Error E2 = new Error(File1, "Error");

			Assert.IsTrue(E1.Equals(E2), "Error.Equals does not return true for identical errors");
		}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:ErrorTestCase.cs


示例14: EqualsWithDifferentMessages

		[Test] public void EqualsWithDifferentMessages()
		{
			Error E1 = new Error(File1, "Error");
			Error E2 = new Error(File1, "Warning");

			Assert.IsFalse(E1.Equals(E2), "Error.Equals does not return false for errors with differing descriptions");
		}
开发者ID:ralescano,项目名称:castle,代码行数:7,代码来源:ErrorTestCase.cs


示例15: ErrorAndMessageConstructorWorks

		public void ErrorAndMessageConstructorWorks() {
			var err = new Error { Message = "Some message" };
			var ex = new JsErrorException(err, "Overridden message");
			Assert.IsTrue((object)ex is JsErrorException, "is JsErrorException");
			Assert.IsTrue(ex.InnerException == null, "InnerException");
			Assert.IsTrue(ReferenceEquals(ex.Error, err), "Error");
			Assert.AreEqual(ex.Message, "Overridden message", "Message");
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:8,代码来源:JsErrorExceptionTests.cs


示例16: Log

 public override string Log(Error error)
 {
     if (error == null)
     {
         throw new ArgumentNullException("error");
     }
     return ExceptionHandler.Report(error.Exception).Id;
 }
开发者ID:janbernloehr,项目名称:vinco-logging-toolkit,代码行数:8,代码来源:HttpErrorLog.cs


示例17: SimpleInMemProtocolErrorException

 public SimpleInMemProtocolErrorException(
     string message,
     Error details,
     Exception innerException)
     : base(message, innerException)
 {
     Details = details;
 }
开发者ID:csdahlberg,项目名称:bond,代码行数:8,代码来源:SimpleInMemProtocolErrorException.cs


示例18: ToStringContainsMessagesCollection

        private void ToStringContainsMessagesCollection()
        {
            var errorMessages = new ErrorMessage[] { new ErrorMessage("key1", "message1"), new ErrorMessage("key2", "message2") };
            var error = new Error("id", errorMessages);

            Assert.Contains("message1", error.ToString());
            Assert.Contains("message2", error.ToString());
        }
开发者ID:digipolisantwerp,项目名称:errors_aspnetcore,代码行数:8,代码来源:ToStringTests.cs


示例19: GetError

 /// <summary>
 /// </summary>
 protected static String GetError(Exception ex, Error? error = null)
 {
     if (ex.IsNull())
         return Format(error: error);
     if (!ex.InnerException.IsNull())
         return Format(ex.InnerException.Message, error);
     return Format(ex.Message, error);
 }
开发者ID:rafaelberrocalj,项目名称:CSharpLess,代码行数:10,代码来源:_Exception.cs


示例20: BarCodeScaner

 public BarCodeScaner()
 {
     ThreadStart ts = new ThreadStart(ReadPort);
       _thread = new Thread(ts);
       _serialPort = new SerialPort();
       _err = new Error();
       _continue = false;
 }
开发者ID:infobook,项目名称:Tools4,代码行数:8,代码来源:BarCodeScaner.cs



注:本文中的System.Error类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# System.EventArgs类代码示例发布时间:2022-05-26
下一篇:
C# System.Environment类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap