This is a migrated thread and some comments may be shown as answers.

Return error With SignalR DS

10 Answers 29 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Veteran
Andy asked on 15 Jan 2021, 08:09 PM
I'm not sure when the change happened, but within the last couple of years I could return an Error property with my SignalR object from my hub and the OnError event of the datasource would be triggered. Now setting that does nothing, and I can throw an exception but the text of my error is buried in a wrapped object, so I'd have to parse the string to get it. Might someone know of a better way to return a server side validation error or a model state dictionary to a SignalR datasource?

10 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 19 Jan 2021, 03:47 PM

Hello Andy,

Could you please elaborate on sharing more details on the case? Namely:

 - Is the data source utilizing a type of "signal"?

 - Can you share the method implementation from the hub? How does it connect to the data source?

Please note that only if the schema.errors option is set and the server response contains that field, then the error event will be fired.

Looking forward to your reply.

Regards,
Nikolay
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Andy
Top achievements
Rank 1
Veteran
answered on 19 Jan 2021, 06:15 PM

Hi Nikolay,

 

Thanks very much for the response. Before I share the implementation, I think it might be good for you to familiarize yourself with SignalR. It's a technology that lets the browser use sockets to retrieve and be sent data rather than requiring polling. Here's a link to an implementation of SignalR

 

https://demos.telerik.com/kendo-ui/grid/signalr
0
Neli
Telerik team
answered on 21 Jan 2021, 01:00 PM

Hello Andy,

As my colleague Nikolay has mentioned in the previous reply, In order to be able to help, we will need more information regarding the exact implementation at your end. It would be very helpful if you could send us an isolated runnable application to replicate the issue so we could be more helpful with a possible solution.

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Andy
Top achievements
Rank 1
Veteran
answered on 21 Jan 2021, 01:05 PM

Hi Neli,

Thanks for the reply. I don't think my question is clear- I don't know how to implement an error property in a signalr data source. I see an example on other data source types, but I don't think those techniques apply to signalr sources. Could you please point me at an example of returning an error message from a signalr data source?

0
Neli
Telerik team
answered on 25 Jan 2021, 10:59 AM

Hi Andy,

I am afraid we do not have an example of returning an error with SignalR dataSource. However, the error event of the DataSource could be used. In case an error is returned from the server, the error event will be triggered. I would suggest you take a look at the forum thread linked below. The thread is regarding UI for ASP.NET Core scenario, but the handing errors with SingalR DataSource is discussed.

- https://www.telerik.com/forums/data-from-signalr-hub-not-visible-in-grid.

 

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Andy
Top achievements
Rank 1
Veteran
answered on 26 Jan 2021, 01:18 AM

Hi Neli,

Sorry, I'm confused. I understand you don't have an example handy, but it is functionality that Telerik provides if I'm not mistaken? If it is, I don't think it's beyond usual support scope to ask for an example. Am I missing something?

0
Neli
Telerik team
answered on 27 Jan 2021, 07:04 PM

Hi Andy,

I used the SingalR sample projects in the repo linked here to test the dataSource behavior. As explained in my previous reply, when the server throws an error, the dataSource error event will be triggered. So for testing purposes, the following exception was thrown when reading the data :

 public IEnumerable<MeetingViewModel> Read(FilterRange range)
        {
            throw new InvalidOperationException("");
        }

Then, the error event handler was triggered. Below is an example of subscribing to the dataSource error event when using Kendo UI for jQuery:

dataSource: { type: "signalr", error: function (e) {

..... console.log(e.xhr) },

The support service provides an explanation of the built-in functionality of our UI components, their configuration, API methods, and events. We often provide code snippets as guidance for achieving the needed result.  Above you could find such an example of how to subscribe to the error event handler when using our components with SignalR dataSource. In case you have additional questions related to the components configuration, please let us know. 

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Andy
Top achievements
Rank 1
Veteran
answered on 27 Jan 2021, 07:33 PM

Hi Neli,

 

Thanks for the reply. It looks like I wasn't clear enough about where I was stuck. I have an error handler and know how to wire it up, and it's hit. The issue is that throwing an exception results in an XHR along these lines:

 

"An unexpected error occurred invoking 'create' on the server. Exception: [FromDate, This appointment falls outside of working hours]"

 

So you can see how it'd be a good deal of work to extract out the portion inside the brackets that wasn't previously necessary. Before I upgraded (I'm not sure which version lost this function) I could add an Error property onto the object being returned and that error message was available in the error handler without any parsing. Can you tell me what functionality should replace that? I don't think the intention is for me to parse out the error, so I'm hoping you can provide a better solution?

0
Andy
Top achievements
Rank 1
Veteran
answered on 27 Jan 2021, 08:02 PM

Sorry to post right back, but I've solved my issue. I was looking for this:

 

https://docs.telerik.com/kendo-ui/api/javascript/data/datasource/configuration/schema#schemaerrors

 

I'd removed the mapping of the errors property of the schema to my property named Error, so I was no longer triggering the error datasource method by setting that Error property. Hope this helps someone else, and sorry I couldn't explain it well enough for you to know what I was after. Thanks for the effort anyway!

0
Neli
Telerik team
answered on 29 Jan 2021, 12:31 PM

Hello Andy,

I am glad that you have managed to resolve the issue by yourself. Thank you very much for sharing more information about the issue and the working solution. I am sure it will be helpful to the other users in the community. 

Regards,
Neli
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Data Source
Asked by
Andy
Top achievements
Rank 1
Veteran
Answers by
Nikolay
Telerik team
Andy
Top achievements
Rank 1
Veteran
Neli
Telerik team
Share this question
or