MCPcopy Create free account
hub / github.com/ElemeFE/element-react / getError

Function getError

src/upload/ajax.js:1–16  ·  view source on GitHub ↗
(action, option, xhr)

Source from the content-addressed store, hash-verified

1function getError(action, option, xhr) {
2 let msg;
3 if (xhr.response) {
4 msg = `${xhr.status} ${xhr.response.error || xhr.response}`;
5 } else if (xhr.responseText) {
6 msg = `${xhr.status} ${xhr.responseText}`;
7 } else {
8 msg = `fail to post ${action} ${xhr.status}`;
9 }
10
11 const err = new Error(msg);
12 err.status = xhr.status;
13 err.method = 'post';
14 err.url = action;
15 return err;
16}
17
18function getBody(xhr) {
19 const text = xhr.responseText || xhr.response;

Callers 1

uploadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected