Skip to content
This repository

Improve error message #805

Merged
merged 2 commits into from about 1 year ago

3 participants

Ryunosuke SATO Mat Brennan Stefan Penner
Ryunosuke SATO

fixture is an instance of Object.

Before:

the id property must be defined for fixture [Object object]

After:

the id property must be defined for fixture {"foo": "bar"}
Ryunosuke SATO Improve error message
`fixture` is an instance of `Object`.

Before:
```
the id property must be defined for fixture [Object object]
```

After:
```
the id property must be defined for fixture {"foo": "bar"}
```
5546806
Mat Brennan

Something to consider is obviously browser support.
http://caniuse.com/json

This gets my :thumbsup: though

Stefan Penner
Owner

@tricknotes a quick feature sniff + fallback should do the trick.

Ryunosuke SATO

@stefanpenner Okay. I did it.

Stefan Penner stefanpenner merged commit 830420a into from March 17, 2013
Stefan Penner stefanpenner closed this March 17, 2013
Ryunosuke SATO tricknotes deleted the branch March 17, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Mar 14, 2013
Ryunosuke SATO Improve error message
`fixture` is an instance of `Object`.

Before:
```
the id property must be defined for fixture [Object object]
```

After:
```
the id property must be defined for fixture {"foo": "bar"}
```
5546806
Mar 15, 2013
Ryunosuke SATO Use `toString` if environment doesn't support `JSON.stringify` a21bd02
This page is out of date. Refresh to see the latest.
5  packages/ember-data/lib/adapters/fixture_adapter.js
@@ -2,7 +2,8 @@ require("ember-data/core");
2 2
 require("ember-data/system/adapter");
3 3
 require('ember-data/serializers/fixture_serializer');
4 4
 
5  
-var get = Ember.get, fmt = Ember.String.fmt;
  5
+var get = Ember.get, fmt = Ember.String.fmt,
  6
+    dump = Ember.get(window, 'JSON.stringify') || function(object) { return object.toString(); };
6 7
 
7 8
 /**
8 9
   `DS.FixtureAdapter` is an adapter that loads records from memory.
@@ -30,7 +31,7 @@ DS.FixtureAdapter = DS.Adapter.extend({
30 31
       var fixtures = Ember.A(type.FIXTURES);
31 32
       return fixtures.map(function(fixture){
32 33
         if(!fixture.id){
33  
-          throw new Error(fmt('the id property must be defined for fixture %@', [fixture]));
  34
+          throw new Error(fmt('the id property must be defined for fixture %@', [dump(fixture)]));
34 35
         }
35 36
         fixture.id = fixture.id + '';
36 37
         return fixture;
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.