Catch errors in promise functions

How I can catch/see errors in promise functions?

webix.ajax().headers({
	"Content-type": "application/json"
}).post("someurl", JSON.stringify(data)).then(function (data) {
	data = data.json();

	// here is some error
	// ...
}).fail(function (request) {
	// or might be here
	// ...
});

If there are any errors in “then”, “fail” functions It’s quite difficult to fix it.

“console.log” will be empty.

I have to use try-catch construction in each method to see errors. It’s superfluously.

Actually you need not use try-catch.
If you will have an error in any of “then” blocks, the error will be catched automatically and “fail” block will be executed.

If you want to catch a error in fail section, you can add one more “fail” block

webix.ajax("http://webix.com").then(function(res){
  webix.message("done");
  throw "some error";
}).fail(function(){
  webix.message("error in then section catched");
  throw "fail error";
}).fail(function(){
  webix.message("error in fail section catched");
})

http://webix.com/snippet/ea5e6173

Also, if you are using webix_debug.js, all non-processed errors will be processed in normal way ( registered in js console, stop debugger when you are using dev. tools, etc. )

If you are using webix.js, non-processed errors in “then” and “fail” blocks will be caught silently

Great! fail after fail.
Thx.

Also, if you are using webix_debug.js, all non-processed errors will be processed in normal way ( registered in js console, stop debugger when you are using dev. tools, etc. )

I’m using webix_debug.js but don’t see any error in the console if I call non-existent functions (e.g. $$('chart').showOverlay()). Only if I put a breakpoint on that line, does Webix stop somewhere in function fire() {...}.