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

fix($templateRequest): propagate HTTP status on failed requests #10628

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ng/templateRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ function $TemplateRequestProvider() {
function handleError(resp) {
self.totalPendingRequests--;
if (!ignoreRequestError) {
throw $compileMinErr('tpload', 'Failed to load template: {0}', tpl);
throw $compileMinErr('tpload', 'Failed to load template: {0} (HTTP status: {1} {2})',
tpl, resp.status, resp.statusText);
}
return $q.reject(resp);
}
Expand Down
4 changes: 2 additions & 2 deletions test/ng/templateRequestSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('$templateRequest', function() {
it('should throw an error when the template is not found',
inject(function($rootScope, $templateRequest, $httpBackend) {

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

$templateRequest('tpl.html');

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

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