Can't catch error from server

Hello webix,
I use
it's ok when server execute successful, but if server
throw new Error().
The Error only show on server, in browser console log
500 (Internal Server Error)

I dont know how to catch it on the client side and show it by webix.message



  • edited November 2019

    try to use catch method

        .catch(err => {
  • it's only show on the console that:

    app.js:63 Uncaught DOMException: Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'blob').

  • Hello @duynq2197 ,
    Unfortunately, I can’t repeat the described issue. Could you please provide more details?
    As an alternative to the catch() method, you could try using the onAjaxError event:

    webix.attachEvent("onAjaxError", function(xhr){
        webix.message({type: 'error', text:"Please try again"});
  • hi.
    onAjaxError can catch this error. And "Uncaught DOMException: Failed to read the 'responseText' property from 'XMLHttpRequest'" notice came from that thing.

    The case is :
    In client
    In server:
    i use 'docxtemplater' lib to create word file and res.end(out, 'binary')


  • Because blob is returned in the response (responseType = blob). Additionally, you need to process this blob (so it still contains an error message).
    To do this, you can use the built-in browser object of type FileReader (it can read data from Blob (and from File, too)) and its API:

    webix.attachEvent("onAjaxError", function(xhr){
      const reader = new FileReader();
      let response;
      reader.onloadend = (e) => {
        response = JSON.parse(reader.result);
      reader.readAsText(xhr.response);  //read the data as a text string with the given encoding (utf-8 by default)
        webix.message({type: 'error', text:"Please try again"});
  • ok it's really ok. I wish webix will improve to handle this . Thanks

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!