fix(ngResource): make badcfg error message more helpful

The error message should help identify the problem. To do so, more details need to be provided.

Closes #9005
Closes #9010
This commit is contained in:
Caitlin Potter
2014-09-10 07:20:31 -04:00
parent eb4afd45f7
commit a3962f0df3
2 changed files with 4 additions and 5 deletions

View File

@@ -579,9 +579,8 @@ angular.module('ngResource', ['ng']).
// jshint -W018
if (angular.isArray(data) !== (!!action.isArray)) {
throw $resourceMinErr('badcfg',
'Error in resource configuration. Expected ' +
'response to contain an {0} but got an {1}',
action.isArray ? 'array' : 'object',
'Error in resource configuration for action `{0}`. Expected response to ' +
'contain an {1} but got an {2}', name, action.isArray ? 'array' : 'object',
angular.isArray(data) ? 'array' : 'object');
}
// jshint +W018

View File

@@ -1320,7 +1320,7 @@ describe('resource', function() {
expect(successSpy).not.toHaveBeenCalled();
expect(failureSpy).toHaveBeenCalled();
expect(failureSpy.mostRecentCall.args[0]).toMatch(
/^\[\$resource:badcfg\] Error in resource configuration\. Expected response to contain an array but got an object/
/^\[\$resource:badcfg\] Error in resource configuration for action `query`\. Expected response to contain an array but got an object/
);
});
@@ -1337,7 +1337,7 @@ describe('resource', function() {
expect(successSpy).not.toHaveBeenCalled();
expect(failureSpy).toHaveBeenCalled();
expect(failureSpy.mostRecentCall.args[0]).toMatch(
/^\[\$resource:badcfg\] Error in resource configuration. Expected response to contain an object but got an array/
/^\[\$resource:badcfg\] Error in resource configuration for action `get`\. Expected response to contain an object but got an array/
);
});