mirror of
https://github.com/discourse/discourse.git
synced 2025-04-02 06:31:34 +08:00
DEV: Provide a nicer error when JSON is malformed
This is very useful for development. It will give a much nicer error if the JSON that comes back from the server is missing a required key.
This commit is contained in:
parent
c9bd463e9d
commit
4422d9a4bf
@ -219,6 +219,13 @@ export default EmberObject.extend({
|
||||
_resultSet(type, result, findArgs) {
|
||||
const adapter = this.adapterFor(type);
|
||||
const typeName = underscore(this.pluralize(adapter.apiNameFor(type)));
|
||||
|
||||
if (!result[typeName]) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(`JSON response is missing \`${typeName}\` key`, result);
|
||||
return;
|
||||
}
|
||||
|
||||
const content = result[typeName].map(obj =>
|
||||
this._hydrate(type, obj, result)
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user