corelibraries-devexpress-dot-dataaccess-dot-json-07478fc2.md
An exception that occurs when an attempt to fill a JsonDataSource with data fails.
Namespace : DevExpress.DataAccess.Json
Assembly : DevExpress.DataAccess.v25.2.dll
NuGet Package : DevExpress.DataAccess
public class JsonDataSourceException :
Exception
Public Class JsonDataSourceException
Inherits Exception
The JsonDataSourceException is thrown when a call to the Fill() method fails to populate the data source with data and supercedes the following exceptions:
Enclose the JsonDataSource.Fill method call in the try block and catch JsonDataSourceException :
try {
dataSource.Fill()
}
catch(JsonDataSourceException) {
//do something
}
Try
dataSource.Fill()
Catch e1 As JsonDataSourceException
'do something
End Try
As an alternative to catching JsonDataSourceException , you can handle the JsonDataSource.FillError event to process WebException , IOException , and JSON data parse errors.
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.
}
Imports DevExpress.DataAccess
Imports DevExpress.DataAccess.Json
' ...
' Create a new JSON source.
Dim jsonSource = New UriJsonSource() With {.Uri = New Uri("https://invalid.json")}
' Assign the JSON source to the data source.
Dim datasource = New JsonDataSource() With {.JsonSource = jsonSource}
Try
datasource.Fill()
Catch e1 As JsonDataSourceException
' Add code to process JsonDataSourceException here.
End Try
Object Exception JsonDataSourceException
See Also