[request] Clearer error message for JSON deserialization failure (#2195)
This commit is contained in:
parent
e46d03f467
commit
fd7cf8041e
3 changed files with 3 additions and 2 deletions
|
|
@ -32,6 +32,7 @@
|
|||
- API: Introduction of `m.redraw.sync()` ([#1592](https://github.com/MithrilJS/mithril.js/pull/1592))
|
||||
- API: Event handlers may also be objects with `handleEvent` methods ([#1939](https://github.com/MithrilJS/mithril.js/issues/1939)).
|
||||
- API: `m.route.link` accepts an optional `options` object ([#1930](https://github.com/MithrilJS/mithril.js/pull/1930))
|
||||
- API: `m.request` better error message on JSON parse error - ([#2195](https://github.com/MithrilJS/mithril.js/pull/2195), [@codeclown](https://github.com/codeclown))
|
||||
- API: `m.request` supports `timeout` as attr - ([#1966](https://github.com/MithrilJS/mithril.js/pull/1966))
|
||||
- Mocks: add limited support for the DOMParser API ([#2097](https://github.com/MithrilJS/mithril.js/pull/2097))
|
||||
- API: add support for raw SVG in `m.trust()` string ([#2097](https://github.com/MithrilJS/mithril.js/pull/2097))
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ module.exports = function($window, Promise) {
|
|||
|
||||
function deserialize(data) {
|
||||
try {return data !== "" ? JSON.parse(data) : null}
|
||||
catch (e) {throw new Error(data)}
|
||||
catch (e) {throw new Error("Invalid JSON: " + data)}
|
||||
}
|
||||
|
||||
function extract(xhr) {return xhr.responseText}
|
||||
|
|
|
|||
|
|
@ -494,7 +494,7 @@ o.spec("xhr", function() {
|
|||
}
|
||||
})
|
||||
xhr({method: "GET", url: "/item"}).catch(function(e) {
|
||||
o(e.message).equals("error")
|
||||
o(e.message).equals("Invalid JSON: error")
|
||||
}).then(done)
|
||||
})
|
||||
o("triggers all branched catches upon rejection", function(done) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue