Skip to content

Commit

Permalink
Let GetCssBlocks add a warning to the list instead of throwing an exc…
Browse files Browse the repository at this point in the history
…eption when a resource could not be downloaded.
  • Loading branch information
W Hörchner committed Feb 2, 2024
1 parent ea8b0e4 commit 813b6ca
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion PreMailer.Net/PreMailer.Net/PreMailer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,19 @@ private bool DomainMatch(string domain, string url)
/// </summary>
private IEnumerable<string> GetCssBlocks(IEnumerable<ICssSource> cssSources)
{
return cssSources.Select(styleSource => styleSource.GetCss()).ToList();
return cssSources.Select(GetCssBlock).ToList();
}
private string GetCssBlock(ICssSource cssSource)
{
try
{
return cssSource.GetCss();
}
catch (Exception ex)
{
_warnings.Add(ex.Message);
return string.Empty;
}
}

private void RemoveCssComments(IEnumerable<IElement> cssSourceNodes)
Expand Down

0 comments on commit 813b6ca

Please sign in to comment.