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

Commit f645882

Browse files
fix($emplateRequest): propagate rejection reason when ignoreRequestError flag is set
Closes #10266
1 parent ab25311 commit f645882

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/ng/templateRequest.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ function $TemplateRequestProvider() {
4848
return html;
4949
}, handleError);
5050

51-
function handleError() {
51+
function handleError(resp) {
5252
self.totalPendingRequests--;
5353
if (!ignoreRequestError) {
5454
throw $compileMinErr('tpload', 'Failed to load template: {0}', tpl);
5555
}
56-
return $q.reject();
56+
return $q.reject(resp);
5757
}
5858
}
5959

test/ng/templateRequestSpec.js

+14
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ describe('$templateRequest', function() {
4343
}).toThrowMinErr('$compile', 'tpload', 'Failed to load template: tpl.html');
4444
}));
4545

46+
it('should not throw when the template is not found and ignoreRequestError is true',
47+
inject(function($rootScope, $templateRequest, $httpBackend) {
48+
49+
$httpBackend.expectGET('tpl.html').respond(404);
50+
51+
var err;
52+
$templateRequest('tpl.html', true).catch(function(reason) { err = reason; });
53+
54+
$rootScope.$digest();
55+
$httpBackend.flush();
56+
57+
expect(err.status).toBe(404);
58+
}));
59+
4660
it('should not throw an error when the template is empty',
4761
inject(function($rootScope, $templateRequest, $httpBackend) {
4862

0 commit comments

Comments
 (0)