Skip to content

Commit

Permalink
improved error
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Aug 16, 2024
1 parent 39e09d9 commit 8c767d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [1.12.11] - Unreleased
### Fixed
- Improved error if the source is not a string.

## [1.12.10] - 2024-07-17
### Fixed
- `auto_trim` plugin throws if there are no next tokens [#73].
Expand Down Expand Up @@ -252,6 +256,7 @@ First version
[#72]: https://github.com/oscarotero/vento/issues/72
[#73]: https://github.com/oscarotero/vento/issues/73

[1.12.11]: https://github.com/oscarotero/vento/compare/v1.12.10...HEAD
[1.12.10]: https://github.com/oscarotero/vento/compare/v0.12.9...v1.12.10
[0.12.9]: https://github.com/oscarotero/vento/compare/v0.12.8...v0.12.9
[0.12.8]: https://github.com/oscarotero/vento/compare/v0.12.7...v0.12.8
Expand Down
5 changes: 5 additions & 0 deletions src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ export class Environment {
defaults?: Record<string, unknown>,
sync = false,
): Template | TemplateSync {
if (typeof source !== "string") {
throw new Error(
`The source code of "${path}" must be a string. Got ${typeof source}`,
);
}
const tokens = this.tokenize(source, path);
let code = this.compileTokens(tokens).join("\n");

Expand Down

0 comments on commit 8c767d4

Please sign in to comment.