Skip to content

Error Handling

Peter Gill edited this page Jun 8, 2026 · 3 revisions

Error Handling

The Report object exposes three members for inspecting errors that occur during parsing and rendering.

Member Type Description
ErrorMaxSeverity int Highest severity level seen so far. 4 or below means the report can still run. 5 or above means it cannot.
ErrorItems IList List of error message strings accumulated since the last ErrorReset().
ErrorReset() method Clears ErrorItems and resets ErrorMaxSeverity to 0.

Severity levels

Severity Meaning
1–4 Warning — report continues running. Output may be incomplete or incorrect in the affected area.
5+ Fatal — report cannot run. Do not call RunGetData or RunRender.

Checking errors after Parse

using Majorsilence.Reporting.Rdl;

RdlEngineConfig.RdlEngineConfigInit();

var rdlp = new RDLParser(await System.IO.File.ReadAllTextAsync("report.rdl"));
using var report = await rdlp.Parse();

if (report.ErrorMaxSeverity > 0)
{
    foreach (string msg in report.ErrorItems)
        Console.WriteLine("Parse error: " + msg);

    if (report.ErrorMaxSeverity > 4)
    {
        Console.WriteLine("Report cannot run — aborting.");
        return;
    }

    // Severity <= 4: warnings only, reset and continue
    report.ErrorReset();
}

await report.RunGetData(null);

Checking errors after RunGetData / RunRender

Errors can also be generated during data retrieval and rendering. Check again after each step if you need complete diagnostics.

await report.RunGetData(null);

if (report.ErrorMaxSeverity > 4)
{
    Console.WriteLine("Data retrieval failed:");
    foreach (string msg in report.ErrorItems)
        Console.WriteLine("  " + msg);
    return;
}

var sg = new OneFileStreamGen("output.pdf", true);
await report.RunRender(sg, OutputPresentationType.PDF);

if (report.ErrorMaxSeverity > 0)
{
    Console.WriteLine("Render warnings:");
    foreach (string msg in report.ErrorItems)
        Console.WriteLine("  " + msg);
}

ASP.NET Core — return errors to the caller

using var report = await rdlp.Parse();

if (report.ErrorMaxSeverity > 4)
{
    var errors = report.ErrorItems.Cast<string>().ToArray();
    return StatusCode(500, new { errors });
}

Common error causes

  • Missing data provider assembly — the DLL named in RdlEngineConfig.xml cannot be found. Fix by checking the provider path or calling RdlEngineConfig.RdlEngineConfigInit(customDir). See Database Providers.
  • Invalid RDL XML — the .rdl file is malformed. Severity 5+, report cannot run.
  • Connection failure — database unreachable during RunGetData. Severity 5.
  • Missing report field — a field referenced in the report is not in the dataset. Severity 1–4, report renders with a blank in that field.
  • Font not found on Linux — SkiaSharp falls back to a default font. Severity 1–4. Install the required fonts; see Linux — PDF export and Fonts.

Clone this wiki locally