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

Commit e24f22b

Browse files
fix($templateRequest): propagate HTTP status on failed requests
Fixes #10514 Closes #10628
1 parent 371c1e1 commit e24f22b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/ng/templateRequest.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ function $TemplateRequestProvider() {
4949
function handleError(resp) {
5050
self.totalPendingRequests--;
5151
if (!ignoreRequestError) {
52-
throw $compileMinErr('tpload', 'Failed to load template: {0}', tpl);
52+
throw $compileMinErr('tpload', 'Failed to load template: {0} (HTTP status: {1} {2})',
53+
tpl, resp.status, resp.statusText);
5354
}
5455
return $q.reject(resp);
5556
}

test/ng/templateRequestSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('$templateRequest', function() {
3939
it('should throw an error when the template is not found',
4040
inject(function($rootScope, $templateRequest, $httpBackend) {
4141

42-
$httpBackend.expectGET('tpl.html').respond(404);
42+
$httpBackend.expectGET('tpl.html').respond(404, '', {}, 'Not found');
4343

4444
$templateRequest('tpl.html');
4545

@@ -48,7 +48,7 @@ describe('$templateRequest', function() {
4848
expect(function() {
4949
$rootScope.$digest();
5050
$httpBackend.flush();
51-
}).toThrowMinErr('$compile', 'tpload', 'Failed to load template: tpl.html');
51+
}).toThrowMinErr('$compile', 'tpload', 'Failed to load template: tpl.html (HTTP status: 404 Not found)');
5252
}));
5353

5454
it('should not throw when the template is not found and ignoreRequestError is true',

0 commit comments

Comments
 (0)