Skip to content

Commit eed6b19

Browse files
authored
Novo atributo no ValidacaoSchemaException para mostrar o xml que teve falha de valiação (#70)
1 parent b8c7783 commit eed6b19

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

NFe.Utils/Excecoes/ValidacaoSchemaException.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ public class ValidacaoSchemaException : Exception
1515
/// Houve erros de validação de schema XSD
1616
/// </summary>
1717
/// <param name="message"></param>
18-
public ValidacaoSchemaException(string message) : base(string.Format("Erros na validação:\n {0}", message)) {}
18+
public ValidacaoSchemaException(string message, string xmlString) : base(
19+
$"Erros na validação:\n {message}")
20+
{
21+
XmlString = xmlString;
22+
}
23+
24+
public string XmlString { get; private set; }
1925
}
20-
}
26+
}

NFe.Utils/Validacao/Validador.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public static string[] Valida(ServicoNFe servicoNFe, VersaoServico versaoServico
172172
}
173173

174174
if (falhas.Length > 0)
175-
throw new ValidacaoSchemaException($"Ocorreu o seguinte erro durante a validação XML: {Environment.NewLine}{falhas}");
175+
throw new ValidacaoSchemaException($"Ocorreu o seguinte erro durante a validação XML: {Environment.NewLine}{falhas}", stringXml);
176176

177177
return falhas.ToString().Trim().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
178178
}

0 commit comments

Comments
 (0)