Tabulator: Documentation unclear on how to handle error (is this comming from the fetch API?)

Created on 21 Nov 2020  路  3Comments  路  Source: olifolkerd/tabulator

Website Page

http://tabulator.info/docs/4.2/data#array

table.setData(tableData)
.then(function(){
    //run code after table has been successfuly updated
})
.catch(function(error){
    //handle error loading data
});

http://tabulator.info/docs/4.8/callbacks#ajax

var table = new Tabulator("#example-table", {
    ajaxError:function(error){
    //error - the returned error object
    },
});

Describe the issue

From the documentation it is unclear how to handle errors.

In the first code snippet it seems that you can catch it as a promise. This is true, but the error object is undefined. It would be nice if you are warned about that, or is that a bug?

In the second you can specify a ajaxError which is also called on an error, and this time there is an error object, but it isn't a classical ajaxError object. It seems to be coming from the fetch API? Can you confirm that? Maybe clarify some things about the error object here, and show how you can deal with this object.

Bug Documentation

Most helpful comment

Hey @hwalinga

I have pushed an update to the 4.9 branch (that will be released later today) to ensure the fetch response object is passed to the promise rejection.

I have also update the 4.9 documentation to make it clearer how to handle ajax errors, this will also go live later today with the 4.9 release.

Thanks for your feedback.

Cheers

Oli :)

All 3 comments

The object is from the fetch API as that is what Tabulator uses under the hood.

What do you mean by an example that shows how to handle the error? That is entirely up to you and would depend on the type of error and your planned action.

I can include a link to the fetch API error documentation if that would be a help

Yes, at least make it clear that is an fetch API error object (or more technically correct, the Body mixin of the fetch API), because otherwise you just start guessing, such as does it have responseText? No, does it have message? etc. It is very non-obvious to instead do a data = await error.json() to get the error response, as fetch isn't that widespread yet.

Hey @hwalinga

I have pushed an update to the 4.9 branch (that will be released later today) to ensure the fetch response object is passed to the promise rejection.

I have also update the 4.9 documentation to make it clearer how to handle ajax errors, this will also go live later today with the 4.9 release.

Thanks for your feedback.

Cheers

Oli :)

Was this page helpful?
0 / 5 - 0 ratings