How do I handle an exception that occurs when generating the data to be sent to the grid? I've seen an example of a call to a Javascript "error_handler" method. Is that my only option?
<
kendo-grid
name
=
"grid"
>
<
datasource
type
=
"DataSourceTagHelperType.Ajax"
on-error
=
"Error"
>
<
transport
>
<
read
url
=
"Home/GetOrgs"
/>
</
transport
>
</
datasource
>
...
</
kendo-grid
>
public IActionResult GetOrgs([DataSourceRequest] DataSourceRequest request)
{
int x = 0; int r = 10 / x;
}
9 Answers, 1 is accepted
By default when a server-side error occurs the relevant information for it would be returned to the client in the Errors field of the response. If you would like to implement additional custom logic in case of an error or prompt the user the recommended option is to use the error event.
Regards,
Viktor Tachev
Progress Telerik

It would be nice to see a failure, but all that I see is an empty grid (no errors). Can you try to reproduce this?
So if I want to handle the error I would need to handle it through Javascript only?
In order for the Grid to display data the response from the Read Action should be in a format that is expected by the DataSource. Thus, make sure that you are calling ToDataSourceRedult to the data returned from the Read ActionMethod.
Please check out the Controller tab in the example below that outlines how a Read action would look:
Regards,
Viktor Tachev
Progress Telerik

The Read action would be operating with data, thus it would return errors that are related to data operations (e.g. database error, db connection problem, etc.). Such errors would be added to the ModelState and returned by the server-side action. Please check out the article below (step7 and step8) that outlines how to return the ModelState with the respective data.
For handling general exceptions in the application I would suggest using the approach described in the following article:
Regards,
Viktor Tachev
Progress Telerik

If you would like to customize the returned result you can define the DataSourceResult manually and specify the Errors field with the relevant information. The example below illustrates how to specify the DataSourceResult fields manually.
Regards,
Viktor Tachev
Progress Telerik

in the link referenced by
"The Read action would be operating with data, thus it would return errors that are related to data operations (e.g. database error, db connection problem, etc.). Such errors would be added to the ModelState and returned by the server-side action. Please check out the article below (step7 and step8) that outlines how to return the ModelState with the respective data. "
I don't see a step 7 and step 8. The link doesn't seem to be related at all to what you are referencing. Can you provide an updated link?
thanks
Hi, Dan,
Thank you for this question.
Our official documentation has been updated and extended a couple of times for the last two years. Find the appropriate article for handling ModelState errors here:
1. For inline editing:
2. Handling Server-side validation errors(blog article):
I hope this information helps.
Kind Regards,
Anton Mironov
Progress Telerik