This repository has been archived on 2023-02-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-my-data/websrc/scripts/tutti/xhr_errors_parser.js
Francesco Siddi c43a7460e6 Improve javascript utilities
Move xhr related functions in dedicated js files.
2018-08-27 08:51:59 +02:00

22 lines
702 B
JavaScript

/* Returns a more-or-less reasonable message given an error response object. */
function xhrErrorResponseMessage(err) {
if (err.status == 0)
return 'Unable to connect to the server, check your internet connection and try again.';
if (typeof err.responseJSON == 'undefined')
return err.statusText;
if (typeof err.responseJSON._error != 'undefined' && typeof err.responseJSON._error.message != 'undefined')
return err.responseJSON._error.message;
if (typeof err.responseJSON._message != 'undefined')
return err.responseJSON._message
if (typeof err.responseJSON.message != 'undefined')
return err.responseJSON.message
return err.statusText;
}