Skip to content

Commit

Permalink
[BUGFIX release] Use detail instead of details for JSON API error…
Browse files Browse the repository at this point in the history
… objects
  • Loading branch information
sebastianseilund committed Jul 6, 2015
1 parent f548244 commit b32b7a9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions packages/ember-data/lib/adapters/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function AdapterError(errors, message = 'Adapter operation failed') {
this.errors = errors || [
{
title: 'Adapter Error',
details: message
detail: message
}
];
}
Expand Down Expand Up @@ -56,11 +56,11 @@ AdapterError.prototype = Object.create(EmberError.prototype);
// Fictional adapter that always rejects
return Ember.RSVP.reject(new DS.InvalidError([
{
details: 'Must be unique',
detail: 'Must be unique',
source: { pointer: 'data/attributes/title' }
},
{
details: 'Must not be blank',
detail: 'Must not be blank',
source: { pointer: 'data/attributes/content'}
}
]));
Expand Down Expand Up @@ -119,7 +119,7 @@ export function errorsHashToArray(errors) {
for (let i = 0; i < messages.length; i++) {
out.push({
title: 'Invalid Attribute',
details: messages[i],
detail: messages[i],
source: {
pointer: `data/attributes/${key}`
}
Expand All @@ -142,7 +142,7 @@ export function errorsArrayToHash(errors) {
if (key) {
key = key[2];
out[key] = out[key] || [];
out[key].push(error.details || error.title);
out[key].push(error.detail || error.title);
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-data/lib/adapters/rest-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ var RESTAdapter = Adapter.extend(BuildURLMixin, {
{
status: `${status}`,
title: "The backend responded with an error",
details: `${payload}`
detail: `${payload}`
}
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,7 @@ test('on error wraps the error string in an DS.AdapterError object', function()
try {
run(function() {
store.find('post', '1').catch(function(err) {
equal(err.errors[0].details, errorThrown);
equal(err.errors[0].detail, errorThrown);
ok(err, 'promise rejected');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,11 @@ test('extractErrors respects custom key mappings', function() {
errors: [
{
source: { pointer: 'data/attributes/le_title' },
details: "title errors"
detail: "title errors"
},
{
source: { pointer: 'data/attributes/my_comments' },
details: "comments errors"
detail: "comments errors"
}
]
};
Expand All @@ -591,7 +591,7 @@ test('extractErrors expects error information located on the errors property of
errors: [
{
source: { pointer: 'data/attributes/title' },
details: "title errors"
detail: "title errors"
}
]
};
Expand Down
8 changes: 4 additions & 4 deletions packages/ember-data/tests/unit/adapter-errors-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ var errorsHash = {
var errorsArray = [
{
title: 'Invalid Attribute',
details: 'is invalid',
detail: 'is invalid',
source: { pointer: 'data/attributes/name' }
},
{
title: 'Invalid Attribute',
details: 'must be a string',
detail: 'must be a string',
source: { pointer: 'data/attributes/name' }
},
{
title: 'Invalid Attribute',
details: 'must be a number',
detail: 'must be a number',
source: { pointer: 'data/attributes/age' }
}
];
Expand All @@ -67,7 +67,7 @@ test("DS.InvalidError will normalize errors hash with deprecation", function() {
deepEqual(error.errors, [
{
title: 'Invalid Attribute',
details: 'is invalid',
detail: 'is invalid',
source: { pointer: 'data/attributes/name' }
}
]);
Expand Down

0 comments on commit b32b7a9

Please sign in to comment.