Elmah.MySqlErrorLog.GetError C# (CSharp) Méthode

GetError() public méthode

Returns the specified error from the database, or null if it does not exist.
public GetError ( string id ) : ErrorLogEntry
id string
Résultat ErrorLogEntry
        public override ErrorLogEntry GetError(string id)
        {
            if (id == null)
                throw new ArgumentNullException("id");

            if (id.Length == 0)
                throw new ArgumentException(null, "id");

            Guid errorGuid;

            try
            {
                errorGuid = new Guid(id);
            }
            catch (FormatException e)
            {
                throw new ArgumentException(e.Message, "id", e);
            }

            string errorXml = null;

            using (var connection = new MySqlConnection(ConnectionString))
            using (var command = Commands.GetErrorXml(ApplicationName, errorGuid))
            {
                command.Connection = connection;
                connection.Open();

                using (var reader = command.ExecuteReader())
                {
                    Debug.Assert(reader != null);

                    while (reader.Read())
                    {
                        errorXml = reader.GetString("AllXml");
                    }
                    reader.Close();
                }
            }

            if (errorXml == null)
                return null;

            var error = ErrorXml.DecodeString(errorXml);
            return new ErrorLogEntry(this, id, error);
        }