Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit a3962f0

Browse files
committed
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
1 parent eb4afd4 commit a3962f0

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/ngResource/resource.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -579,9 +579,8 @@ angular.module('ngResource', ['ng']).
579579
// jshint -W018
580580
if (angular.isArray(data) !== (!!action.isArray)) {
581581
throw $resourceMinErr('badcfg',
582-
'Error in resource configuration. Expected ' +
583-
'response to contain an {0} but got an {1}',
584-
action.isArray ? 'array' : 'object',
582+
'Error in resource configuration for action `{0}`. Expected response to ' +
583+
'contain an {1} but got an {2}', name, action.isArray ? 'array' : 'object',
585584
angular.isArray(data) ? 'array' : 'object');
586585
}
587586
// jshint +W018

test/ngResource/resourceSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ describe('resource', function() {
13201320
expect(successSpy).not.toHaveBeenCalled();
13211321
expect(failureSpy).toHaveBeenCalled();
13221322
expect(failureSpy.mostRecentCall.args[0]).toMatch(
1323-
/^\[\$resource:badcfg\] Error in resource configuration\. Expected response to contain an array but got an object/
1323+
/^\[\$resource:badcfg\] Error in resource configuration for action `query`\. Expected response to contain an array but got an object/
13241324
);
13251325
});
13261326

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

0 commit comments

Comments
 (0)