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

Commit 266bc65

Browse files
feat($resource): include request context in error message
include the request context (method & url) in badcfg error message Closes #11363
1 parent f0dd7c0 commit 266bc65

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/ngResource/resource.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,8 @@ angular.module('ngResource', ['ng']).
581581
if (angular.isArray(data) !== (!!action.isArray)) {
582582
throw $resourceMinErr('badcfg',
583583
'Error in resource configuration for action `{0}`. Expected response to ' +
584-
'contain an {1} but got an {2}', name, action.isArray ? 'array' : 'object',
585-
angular.isArray(data) ? 'array' : 'object');
584+
'contain an {1} but got an {2} (Request: {3} {4})', name, action.isArray ? 'array' : 'object',
585+
angular.isArray(data) ? 'array' : 'object', httpConfig.method, httpConfig.url);
586586
}
587587
// jshint +W018
588588
if (action.isArray) {

test/ngResource/resourceSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,7 @@ describe('resource', function() {
13271327
expect(successSpy).not.toHaveBeenCalled();
13281328
expect(failureSpy).toHaveBeenCalled();
13291329
expect(failureSpy.mostRecentCall.args[0]).toMatch(
1330-
/^\[\$resource:badcfg\] Error in resource configuration for action `query`\. Expected response to contain an array but got an object/
1330+
/^\[\$resource:badcfg\] Error in resource configuration for action `query`\. Expected response to contain an array but got an object \(Request: GET \/Customer\/123\)/
13311331
);
13321332
});
13331333

@@ -1344,7 +1344,7 @@ describe('resource', function() {
13441344
expect(successSpy).not.toHaveBeenCalled();
13451345
expect(failureSpy).toHaveBeenCalled();
13461346
expect(failureSpy.mostRecentCall.args[0]).toMatch(
1347-
/^\[\$resource:badcfg\] Error in resource configuration for action `get`\. Expected response to contain an object but got an array/
1347+
/^\[\$resource:badcfg\] Error in resource configuration for action `get`\. Expected response to contain an object but got an array \(Request: GET \/Customer\/123\)/
13481348
);
13491349
});
13501350

0 commit comments

Comments
 (0)