Skip to content

Commit 8ce2be4

Browse files
smmhatamijaylinski
authored andcommitted
Improve error-message when partial is missing
Signed-off-by: Seyed Mohammad Mahdi Hatami <[email protected]>
1 parent d3b9357 commit 8ce2be4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/handlebars/runtime.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,9 @@ export function invokePartial(partial, context, options) {
376376
}
377377

378378
if (partial === undefined) {
379-
throw new Exception('The partial ' + options.name + ' could not be found');
379+
throw new Exception(
380+
'The partial "' + options.name + '" could not be found'
381+
);
380382
} else if (partial instanceof Function) {
381383
return partial(context, options);
382384
}

spec/partials.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ describe('partials', function () {
6464
return 'missing';
6565
})
6666
.withPartial('dude', '{{name}} ({{url}}) ')
67-
.toThrow(Handlebars.Exception, 'The partial missing could not be found');
67+
.toThrow(
68+
Handlebars.Exception,
69+
'The partial "missing" could not be found'
70+
);
6871
});
6972

7073
it('partials with context', function () {
@@ -156,7 +159,7 @@ describe('partials', function () {
156159
it('rendering undefined partial throws an exception', function () {
157160
expectTemplate('{{> whatever}}').toThrow(
158161
Handlebars.Exception,
159-
'The partial whatever could not be found'
162+
'The partial "whatever" could not be found'
160163
);
161164
});
162165

@@ -174,7 +177,7 @@ describe('partials', function () {
174177
it('rendering template partial in vm mode throws an exception', function () {
175178
expectTemplate('{{> whatever}}').toThrow(
176179
Handlebars.Exception,
177-
'The partial whatever could not be found'
180+
'The partial "whatever" could not be found'
178181
);
179182
});
180183

@@ -472,7 +475,7 @@ describe('partials', function () {
472475

473476
expectTemplate(
474477
'{{#with .}}{{#*inline "myPartial"}}success{{/inline}}{{/with}}{{> myPartial}}'
475-
).toThrow(Error, /myPartial could not/);
478+
).toThrow(Error, /"myPartial" could not/);
476479
});
477480

478481
it('should override global partials', function () {

0 commit comments

Comments
 (0)