Skip to main content
All docs
V24.1

IErrorJsonSerializer Interface

Serializes errors that occur on the server to send them to the client.

Namespace: DevExpress.XtraReports.Web.ReportDesigner.Services

Assembly: DevExpress.XtraReports.v24.1.Web.dll

NuGet Package: DevExpress.Web.Reporting.Common

Declaration

public interface IErrorJsonSerializer

Remarks

You can implement and register a custom IErrorJsonSerializerservice and use the service to send error information to the client.

The following code snippet is a sample controller that creates a Report Designer View Model and returns it to the client. If an error occurs, the IErrorJsonSerializer service is used to send the information to the client.

[ApiController]
[Authorize]
[Route("api/[controller]")]
public class ReportDesignerSetupController : ControllerBase {
    [HttpPost("[action]")]
    public object GetReportDesignerModel([FromForm] string reportUrl,
        [FromServices] IReportDesignerModelBuilder reportDesignerModel,
        [FromServices] IErrorJsonSerializer errorSerializer,
        [FromServices] IReportDesignerClientSideModelGenerator modelGenerator) {
        Dictionary<string, object> dataSources = new Dictionary<string, object>();
        //Fill a data source set if needed
        if(something_goes_wrong)
            return errorSerializer.FromError("Try again later");

        reportDesignerModel
            .Report(reportUrl)
            .DataSources(dataSources)
            .DesignerUri("/DXXRDAAA")
            .ViewerUri("/DXXRDVAAA")
            .QueryBuilderUri("/DXXQBAAA")
            .BuildJsonModel();
        var model = reportDesignerModel.BuildModel();
        var modelJson = modelGenerator.GetJsonModelScript(model);
        return Content(modelJson, MediaTypeNames.Application.Json);
    }
}
See Also