Skip to main content

JsonDataSourceException Class

An exception that occurs when an attempt to fill a JsonDataSource with data fails.

Namespace: DevExpress.DataAccess.Json

Assembly: DevExpress.DataAccess.v24.1.dll

NuGet Packages: DevExpress.DataAccess, DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap

Declaration

public class JsonDataSourceException :
    Exception

Remarks

The JsonDataSourceException is thrown when a call to the Fill() method fails to populate the data source with data and supercedes the following exceptions:

  • WebExceptions that occur when the endpoint’s Uri is not accessible.
  • IOExceptions that occur on failed attempts to load JSON data from the file system.
  • JSON data parse errors.

Enclose the JsonDataSource.Fill method call in the try block and catch JsonDataSourceException:

try {
  dataSource.Fill()
}
catch(JsonDataSourceException) {
  //do something
}

As an alternative to catching JsonDataSourceException, you can handle the JsonDataSource.FillError event to process WebException, IOException, and JSON data parse errors.

Example

The code sample below creates a new data source, calls the Fill method to populate the data source with data, and catches the JsonDataSourceException exception that may occur during the Fill method call.

using DevExpress.DataAccess;
using DevExpress.DataAccess.Json;
// ...
// Create a new JSON source.
var jsonSource = new UriJsonSource() {
    Uri = new Uri(@"https://invalid.json")
};
// Assign the JSON source to the data source.
var datasource = new JsonDataSource() {
    JsonSource = jsonSource
};
try {
    datasource.Fill();
}
catch (JsonDataSourceException) {
    // Add code to process JsonDataSourceException here.
}

Inheritance

Object
Exception
JsonDataSourceException
See Also