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

DataSource "error" event is not firing

8 Answers 674 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Bilal
Top achievements
Rank 2
Bilal asked on 26 Feb 2015, 08:54 PM
Hi,

I am hooking into the error event to handle errors returned from server.

The server currently sends to client, in case of errors, something like this:
{"errors":[{"id":"b128083a-4027-431b-a04b-7485530e347a","errorMessage":"Account failed to update"}]}

As for the Data Source configuration:
schema: { errors: "errors" }
error: function(e) {console.log(e.errors);}

However, the error event doesn't fire.
Is there something I am missing?

Regards
Bilal

8 Answers, 1 is accepted

Sort by
0
Bilal
Top achievements
Rank 2
answered on 26 Feb 2015, 10:16 PM
This is now the exception I am getting:

0
Bilal
Top achievements
Rank 2
answered on 26 Feb 2015, 10:22 PM

2015-02-27 00:20:28.445VM214:3 Uncaught TypeError: Cannot read property 'errors' of undefined     VM214:3
(anonymous function)kendo.all.min.js:11
ht.extend._handleCustomErrorskendo.all.min.js:11
ht.extend._acceptkendo.all.min.js:11
(anonymous function)jquery.min.js:3
(anonymous function)jquery.min.js:3
cjquery.min.js:3 p.fireWithjquery.min.js:3 b.each.i.(anonymous function)kendo.all.min.js:11 e.Deferred.r.transport.(anonymous function).call.tt.successjquery.min.js:3 cjquery.min.js:3 p.fireWithjquery.min.js:5 kjquery.min.js:5 send.r
0
Bilal
Top achievements
Rank 2
answered on 27 Feb 2015, 07:47 AM
I noticed in the "Preview" tab of Chrome, the response is shown as:


Seems "errors" are wrapped inside an object and DataSource not seeing the "errors" property!

0
Bilal
Top achievements
Rank 2
answered on 27 Feb 2015, 07:49 AM
Please find attached image.
0
Bilal
Top achievements
Rank 2
answered on 27 Feb 2015, 08:16 AM
More debugging from inside Parse function:
0
Bilal
Top achievements
Rank 2
answered on 27 Feb 2015, 03:22 PM
This issue has been resolved. 
I debugged my application using kendo.web.js file and I noticed that in my case, I am implementing "Parse" function and in my return values I am hiding errors, so now this is fixed and I am returning the errors in case they exist.

Best regards
Bilal Haidar
0
zhang
Top achievements
Rank 1
answered on 16 Apr 2018, 12:19 PM

Hello,How do you resovle this problem?

My return json format is: {success:true,msg:'error',error:'error'},

but can not fire schema errors.

0
Alex Hajigeorgieva
Telerik team
answered on 18 Apr 2018, 10:52 AM
Hello, Zhang,

For the errors to be intercepted correctly, the errors object should be a valid JSON. After that, the dataSource schema errors handler works as described in the documentation:

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

{"success":true,"msg":"error","error":"error"}

Here is a runnable Dojo that you can test with: https://dojo.telerik.com/@bubblemaster/ExOLanIl

schema: {
  data: "items",
  errors: function(response) {     
    console.log("Errors as function. Message: ", response.error)
    return response.error;
  }
},
error: function(e) {
  console.log("Error event handler. Message: ", e.errors);
}

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Data Source
Asked by
Bilal
Top achievements
Rank 2
Answers by
Bilal
Top achievements
Rank 2
zhang
Top achievements
Rank 1
Alex Hajigeorgieva
Telerik team
Share this question
or