improve error when error response is not JSON
This commit is contained in:
parent
161fbec443
commit
0f4f263441
2 changed files with 19 additions and 1 deletions
|
|
@ -521,7 +521,8 @@ Mithril = m = new function app(window) {
|
|||
deferred[e.type == "load" ? "resolve" : "reject"](response)
|
||||
}
|
||||
catch (e) {
|
||||
if (e instanceof Error && e.constructor !== Error) throw e
|
||||
if (e instanceof SyntaxError) throw new SyntaxError("Could not parse HTTP response. See http://lhorie.github.io/mithril/mithril.request.html#using-variable-data-formats")
|
||||
else if (e instanceof Error && e.constructor !== Error) throw e
|
||||
else deferred.reject(e)
|
||||
}
|
||||
if (xhrOptions.background !== true) m.endComputation()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue