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;
using (var connection = CreateOpenConnection())
using (var command = connection.CreateCommand())
{
command.CommandText = SchemaOwner + "pkg_elmah$get_error.GetErrorXml";
command.CommandType = CommandType.StoredProcedure;
var addParameter = command.ParameterAdder();
addParameter("v_Application", DbType.String, ApplicationName);
addParameter("v_ErrorId", DbType.String, errorGuid.ToString("N"));
var allXml = AddProviderSpecificTypeParameter(command, "v_AllXml", ThisProviderInfo.ClobDbType);
allXml.Direction = ParameterDirection.Output;
command.ExecuteNonQuery();
errorXml = allXml.Value as string;
if (errorXml == null)
{
// TODO Review whether Stream needs disposing
var stream = (Stream) allXml.Value;
var reader = new StreamReader(stream, Encoding.Unicode);
errorXml = reader.ReadToEnd();
}
}
var error = ErrorXml.DecodeString(errorXml);
return new ErrorLogEntry(this, id, error);
}