Permalink
Browse files

feat($resource): include request context in error message

include the request context (method & url) in badcfg error message

Closes #11363
  • Loading branch information...
1 parent f0dd7c0 commit 266bc6520ba4d188dbc949643def102604f98905 @Jaco-Pretorius Jaco-Pretorius committed with pkozlowski-opensource Mar 18, 2015
Showing with 4 additions and 4 deletions.
  1. +2 −2 src/ngResource/resource.js
  2. +2 −2 test/ngResource/resourceSpec.js
@@ -581,8 +581,8 @@ angular.module('ngResource', ['ng']).
if (angular.isArray(data) !== (!!action.isArray)) {
throw $resourceMinErr('badcfg',
'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');
+ 'contain an {1} but got an {2} (Request: {3} {4})', name, action.isArray ? 'array' : 'object',
+ angular.isArray(data) ? 'array' : 'object', httpConfig.method, httpConfig.url);
}
// jshint +W018
if (action.isArray) {
@@ -1327,7 +1327,7 @@ describe('resource', function() {
expect(successSpy).not.toHaveBeenCalled();
expect(failureSpy).toHaveBeenCalled();
expect(failureSpy.mostRecentCall.args[0]).toMatch(
- /^\[\$resource:badcfg\] Error in resource configuration for action `query`\. 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 \(Request: GET \/Customer\/123\)/
);
});
@@ -1344,7 +1344,7 @@ describe('resource', function() {
expect(successSpy).not.toHaveBeenCalled();
expect(failureSpy).toHaveBeenCalled();
expect(failureSpy.mostRecentCall.args[0]).toMatch(
- /^\[\$resource:badcfg\] Error in resource configuration for action `get`\. 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 \(Request: GET \/Customer\/123\)/
);
});

0 comments on commit 266bc65

Please sign in to comment.