More friendly exception when datasource empty
andreykhr opened this issue · 2 comments
andreykhr commented
Summary of the issue
Environment
The in-use version:
Operating system: OS X 10.14.2
IDE: Rider 2018.1
Example code/Steps to reproduce:
Based on example https://github.com/VahidN/PdfReport.Core/blob/master/src/PdfRpt.Core.FunctionalTests/IListPdfReport.cs
If comment datasource line №79 is fails on null reference exception.
Suppose it must throw some another exceptions. More understandable, something like 'datasource' not configured properly or datasource is empty.
.MainTableDataSource(dataSource =>
{
var listOfRows = new List<User>
{
new User {Id = 0, LastName = "Test Degree Sign: 120°", Name = "Celsius", Balance = 0}
};
for (var i = 1; i <= 200; i++)
{
listOfRows.Add(new User { Id = i, LastName = "LastName " + i, Name = "Name " + i, Balance = i + 1000 });
}
// dataSource.StronglyTypedList(listOfRows);
})
another one
// .MainTableDataSource(dataSource =>
// {
// var listOfRows = new List<User>
// {
// new User {Id = 0, LastName = "Test Degree Sign: 120°", Name = "Celsius", Balance = 0}
// };
// for (var i = 1; i <= 200; i++)
// {
// listOfRows.Add(new User { Id = i, LastName = "LastName " + i, Name = "Name " + i, Balance = i + 1000 });
// }
// dataSource.StronglyTypedList(listOfRows);
// })
Output:
Exception message:
System.NullReferenceException : Object reference not set to an instance of an object.
Full Stack trace:
System.NullReferenceException : Object reference not set to an instance of an object.
at PdfRpt.Core.PdfTable.RenderMainTable.setLocalCache()
at PdfRpt.Core.PdfTable.RenderMainTable.initData()
at PdfRpt.Core.PdfTable.RenderMainTable.AddToDocument()
at PdfRpt.PdfReportDocument.createPdf()
at PdfRpt.PdfReportDocument.GeneratePdf()
at PdfRpt.FluentInterface.PdfReport.Generate(Action`1 pdfRptFileBuilder)
at Tests.Tests.CreateIListPdfReport() in /Users/andreykhr/src/KhramtSoft/PdfFixGen/IssueTest/TestProject1/UnitTest1.cs:line 25
at Tests.Tests.Test1() in /Users/andreykhr/src/KhramtSoft/PdfFixGen/IssueTest/TestProject1/UnitTest1.cs:line 19
lock commented
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.