当前位置: 首页>>代码示例>>C#>>正文


C# Error类代码示例

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


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

示例1: Log

		public override string Log(Error error)
		{
			if (error == null)
			{
				throw new ArgumentNullException(nameof(error));
			}

			var errorXml = ErrorXml.EncodeString(error);

			using (var scope = DataAccessScope.CreateReadCommitted())
			{
				var dbElmahError = dataModel.ElmahErrors.Create();

				dbElmahError.Application = ApplicationName;
				dbElmahError.Host = error.HostName;
				dbElmahError.Type = error.Type;
				dbElmahError.Source = error.Source;
				dbElmahError.Message = error.Message;
				dbElmahError.User = error.User;
				dbElmahError.StatusCode = error.StatusCode;
				dbElmahError.TimeUtc = error.Time;
				dbElmahError.AllXml = errorXml;

				scope.Complete();

				return dbElmahError.Id.ToString();
			}
		}
开发者ID:samcook,项目名称:Elmah.Shaolinq,代码行数:28,代码来源:ShaolinqErrorLog.cs

示例2: Append

 protected override void Append(log4net.Core.LoggingEvent loggingEvent)
 {
     if (this._ErrorLog != null)
     {
         Error error;
         if (loggingEvent.ExceptionObject != null)
         {
             error = new Error(loggingEvent.ExceptionObject);
         }
         else
         {
             error = new Error();
         }
         error.Time = DateTime.Now;
         if (loggingEvent.MessageObject != null)
         {
             error.Message = loggingEvent.MessageObject.ToString();
         }
         error.Detail = base.RenderLoggingEvent(loggingEvent);
         error.HostName = this._HostName;
         error.User = loggingEvent.Identity;
         error.Type = "log4net - " + loggingEvent.Level; // maybe allow the type to be customized?
         this._ErrorLog.Log(error);
     }
 }
开发者ID:jmachale,项目名称:log4net---ELMAH-Appender,代码行数:25,代码来源:ELMAHAppender.cs

示例3: ErrorLoggingEventArgs

        public ErrorLoggingEventArgs(Error error)
        {
            if (error == null)
                throw new ArgumentNullException("error");

            _error = error;
        }
开发者ID:jaysilk84,项目名称:ELMAH,代码行数:7,代码来源:ErrorLogModule.cs

示例4: Log

        /// <summary>
        /// Logs an error in log for the application.
        /// </summary>
        public override string Log(Error error)
        {
            if (error == null)
                throw new ArgumentNullException("error");

            string errorXml = ErrorXml.EncodeString(error);
            Guid id = Guid.NewGuid();

            using (MySqlConnection cn = new MySqlConnection(ConnectionString))
            {
                using (MySqlCommand cmd = new MySqlCommand("Elmah_LogError", cn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@pErrorId", id.ToString());
                    cmd.Parameters.AddWithValue("@pApplication", ApplicationName);
                    cmd.Parameters.AddWithValue("@pHost", error.HostName);
                    cmd.Parameters.AddWithValue("@pType", error.Type);
                    cmd.Parameters.AddWithValue("@pSource", error.Source);
                    cmd.Parameters.AddWithValue("@pMessage", error.Message);
                    cmd.Parameters.AddWithValue("@pUser", error.User);
                    cmd.Parameters.AddWithValue("@pStatusCode", error.StatusCode);
                    cmd.Parameters.AddWithValue("@pTimeUtc", error.Time.ToUniversalTime());
                    cmd.Parameters.AddWithValue("@pAllXml", errorXml);

                    cn.Open();
                    cmd.ExecuteNonQuery();
                    return id.ToString();
                }
            }
        }
开发者ID:prabirshrestha,项目名称:ELMAH.MySql,代码行数:33,代码来源:MySqlErrorLog.cs

示例5: Decode

        /// <summary>
        /// Decodes an <see cref="Error"/> object from its XML representation.
        /// </summary>
        public static Error Decode(XmlReader reader)
        {
            if (reader == null) throw new ArgumentNullException("reader");
            if (!reader.IsStartElement()) throw new ArgumentException("Reader is not positioned at the start of an element.", "reader");

            //
            // Read out the attributes that contain the simple
            // typed state.
            //

            var error = new Error();
            ReadXmlAttributes(reader, error);

            //
            // Move past the element. If it's not empty, then
            // read also the inner XML that contains complex
            // types like collections.
            //

            var isEmpty = reader.IsEmptyElement;
            reader.Read();

            if (!isEmpty)
            {
                ReadInnerXml(reader, error);
                reader.ReadEndElement();
            }

            return error;
        }
开发者ID:joelowrance,项目名称:Elmah,代码行数:33,代码来源:ErrorXml.cs

示例6: typeof

            void ITableEntity.ReadEntity(IDictionary<string, EntityProperty> properties, Microsoft.WindowsAzure.Storage.OperationContext operationContext)
            {
                // This can occasionally fail because someone didn't finish creating the entity yet.

                EntityProperty value;
                if (properties.TryGetValue("SerializedError", out value))
                {
                    Error = ErrorXml.DecodeString(value.StringValue);
                }
                else
                {
                    Error = new Error
                    {
                        ApplicationName = "TableErrorLog",
                        StatusCode = 999,
                        HostName = Environment.MachineName,
                        Time = DateTime.UtcNow,
                        Type = typeof(Exception).FullName,
                        Detail = "Error Log Entry is Corrupted/Missing in Table Store"
                    };

                    return;
                }

                if (properties.TryGetValue("Detail", out value))
                {
                    Error.Detail = value.StringValue;
                }

                if (properties.TryGetValue("WebHostHtmlMessage", out value))
                {
                    Error.WebHostHtmlMessage = value.StringValue;
                }
            }
开发者ID:henrycomein,项目名称:NuGetGallery,代码行数:34,代码来源:TableErrorLog.cs

示例7: Encode

        /// <summary>
        /// Encodes the default JSON representation of an <see cref="Error"/> 
        /// object to a <see cref="TextWriter" />.
        /// </summary>
        /// <remarks>
        /// Only properties and collection entires with non-null
        /// and non-empty strings are emitted.
        /// </remarks>

        public static void Encode(Error error, TextWriter writer)
        {
            if (error == null) throw new ArgumentNullException("error");            
            if (writer == null) throw new ArgumentNullException("writer");

            EncodeEnclosed(error, new JsonTextWriter(writer));
        }
开发者ID:ramsenthil18,项目名称:elmah,代码行数:16,代码来源:ErrorJson.cs

示例8: InternalServerError

 protected virtual IActionResult InternalServerError(Error error)
 {
     if (error == null) throw new ArgumentNullException("error", "error is null");
     foreach (var message in error.Messages)
         Logger.LogError(message);
     return new ObjectResult(error) { StatusCode = 500 };
 }
开发者ID:digipolisantwerp,项目名称:codetable_aspnetcore,代码行数:7,代码来源:ControllerBase.cs

示例9: GenerateError

        private static Error GenerateError(int maxErrorNestingLevel = 3, bool generateData = true, int currentNestingLevel = 0) {
            var error = new Error();
            error.Message = @"Generated exception message.";
            error.Type = TestConstants.ExceptionTypes.Random();
            if (RandomHelper.GetBool())
                error.Code = RandomHelper.GetRange(-234523453, 98690899).ToString();

            if (generateData) {
                for (int i = 0; i < RandomHelper.GetRange(1, 5); i++) {
                    string key = RandomHelper.GetPronouncableString(RandomHelper.GetRange(5, 15));
                    while (error.Data.ContainsKey(key) || key == Event.KnownDataKeys.Error)
                        key = RandomHelper.GetPronouncableString(RandomHelper.GetRange(5, 15));

                    error.Data.Add(key, RandomHelper.GetPronouncableString(RandomHelper.GetRange(5, 25)));
                }
            }

            var stack = new StackFrameCollection();
            for (int i = 0; i < RandomHelper.GetRange(1, 10); i++)
                stack.Add(GenerateStackFrame());
            error.StackTrace = stack;

            if (currentNestingLevel < maxErrorNestingLevel && RandomHelper.GetBool())
                error.Inner = GenerateError(maxErrorNestingLevel, generateData, currentNestingLevel + 1);

            return error;
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:27,代码来源:EventData.cs

示例10: KeyVaultClientException

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="status">The HTTP response status code</param>
 /// <param name="error">The Error object returned by the service</param>
 public KeyVaultClientException( HttpStatusCode status, Uri requestUri, Error error = null )
     : base( GetExceptionMessage( error ) )
 {
     Error      = error;
     RequestUri = requestUri;
     Status     = status;
 }
开发者ID:Indhukrishna,项目名称:azure-powershell,代码行数:12,代码来源:KeyVaultClientException.cs

示例11: WorkDB

 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="aConnectionString">строка соединения</param>
 public WorkDB(string aConnectionString)
 {
     mCn = new OleDbConnection(aConnectionString);
     mErr = new Error();
       mTxn = null;
       mIsInternalTransaction = false;
 }
开发者ID:infobook,项目名称:Query3,代码行数:11,代码来源:WorkDB.cs

示例12: GetExceptionMessage

        private static string GetExceptionMessage( Error error )
        {
            if ( error != null && !string.IsNullOrWhiteSpace( error.Message ) )
                return error.Message;

            return "Service Error information was not available";
        }
开发者ID:Indhukrishna,项目名称:azure-powershell,代码行数:7,代码来源:KeyVaultClientException.cs

示例13: Error

        /// <summary> 
        /// Constructor 
        /// </summary>
        public Error( Exception ex )
        {
            Message = ex.Message;

            if( ex.InnerException != null )
                InnerError = new Error( ex.InnerException );
        }
开发者ID:darksun190,项目名称:PiWeb-Api,代码行数:10,代码来源:Error.cs

示例14: Enqueue

 public void Enqueue(Error error) {
     Manifest manifest = Manifest.FromError(error);
     manifest.LastAttempt = DateTime.MinValue;
     _data.Add(Tuple.Create(manifest, error));
     while (_data.Count > MaxItems)
         _data.RemoveAt(0);
 }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:7,代码来源:InMemoryQueueStore.cs

示例15: RepublishError

        public void RepublishError(Error error, QueueParameters parameters)
        {
            using (var connection = HosepipeConnection.FromParamters(parameters))
            using (var model = connection.CreateModel())
            {
                try
                {
                    if (error.Exchange != string.Empty)
                    {
                        model.ExchangeDeclarePassive(error.Exchange);
                    }

                    var properties = model.CreateBasicProperties();
                    error.BasicProperties.CopyTo(properties);

                    var body = Encoding.UTF8.GetBytes(error.Message);

                    model.BasicPublish(error.Exchange, error.RoutingKey, properties, body);
                }
                catch (OperationInterruptedException)
                {
                    Console.WriteLine("The exchange, '{0}', described in the error message does not exist on '{1}', '{2}'",
                        error.Exchange, parameters.HostName, parameters.VHost);
                }
            }
        }
开发者ID:richard-green,项目名称:EasyNetQ,代码行数:26,代码来源:ErrorRetry.cs


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