/// <summary>Rotina que retorna um objeto string contendo uma tabela html com os dados referente ao erro enviado por parâmetro
/// </summary>
/// <param name="pObjErr">Objeto Exception com os dados do erro</param>
/// <returns>Retorna um objeto string contendo uma tabela html com os dados referente ao erro</returns>
/// <example>Escrevendo diretamente um arquivo:
/// <code>
/// Geral.EscreverArquivo(token, Geral.MontarMsgErro(e.Error));
/// </code>
/// Armazenando em uma variável para posterior uso:
/// <code>
/// iBody = Geral.MontarMsgErro(objErr);
/// </code>
/// </example>
public static string MontarMsgErro(Exception pObjErr)
{
string pErrorMsg = pObjErr.Message.ToString();
string pInner = (pObjErr.InnerException == null ? String.Empty : pObjErr.InnerException.ToString());
string pType = (pObjErr.GetType().FullName == null ? String.Empty : pObjErr.GetType().FullName.ToString());
string pStack = (pObjErr.StackTrace == null ? String.Empty : pObjErr.StackTrace.ToString());
string pTargetSite = (pObjErr.TargetSite == null ? String.Empty : pObjErr.TargetSite.ToString());
string pSource = (pObjErr.Source == null ? String.Empty : pObjErr.Source.ToString());
return @"
<html content=""text/html; charset=UTF-8"">
<body bgcolor=""#FFFFFF"">
<table width=""85%"" border=""1"" cellspacing=""0"" cellpadding=""1"" bordercolor=""#999999"">
<tr bgcolor=""#CCCCFC"">
<td width=""100%"" colspan=""2"" height=""20"">
<div align=""center""><font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#0000CC""><b>Dados do Erro</b></font></div>
</td>
</tr>
<tr bgcolor=""#CCFFCC"">
<td width=""15%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2""><b><font color=""#000000"">Date</font></b></font>
</td>
<td width=""85%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2""><b><font color=""#000000""> " + DateTime.Now.ToString(_FormatoDataHora) + @" </font></b></font>
</td>
</tr>
<tr bgcolor=""#CCFFCC"">
<td width=""15%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">Error Message</font>
</td>
<td width=""85%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">" + pErrorMsg + @" </font>
</td>
</tr>
<tr bgcolor=""#CCFFCC"">
<td width=""15%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">Inner Exception</font>
</td>
<td width=""85%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">" + pInner + @" </font>
</td>
</tr>
<tr bgcolor=""#CCFFCC"">
<td width=""15%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">Exception Type</font>
</td>
<td width=""85%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">" + pType + @" </font>
</td>
</tr>
<tr bgcolor=""#CCFFCC"">
<td width=""15%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">Stack Trace</font>
</td>
<td width=""85%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">" + pStack + @" </font>
</td>
</tr>
<tr bgcolor=""#CCFFCC"">
<td width=""15%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">Target Site</font>
</td>
<td width=""85%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">" + pTargetSite + @" </font>
</td>
</tr>
<tr bgcolor=""#CCFFCC"">
<td width=""15%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">Source</font>
</td>
<td width=""85%"">
<font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"" color=""#006600"">" + pSource + @" </font>
</td>
</tr>
</table>
</body>
</html>";
}
Nenhum comentário:
Postar um comentário