Skip to content

Commit

Permalink
Lack of local includes should only warn and do not throw an error, be…
Browse files Browse the repository at this point in the history
…cause the data file can perhaps be found by kroki server
  • Loading branch information
mwabik committed Sep 21, 2020
1 parent 23a4a62 commit fe014df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/preprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ function readPlantUmlInclude (url, dirPath, includeStack, vfs) {
try {
text = read(filePath)
} catch (e) {
const message = `Preprocessing of PlantUML include failed, because reading the referenced local file '${filePath}' caused an error:\n${e}`
throw addCauseToError(new Error(message), e)
// Only warn and do not throw an error, because the data file can perhaps be found by kroki server
console.warn(`Skipping preprocessing of PlantUML include, because reading the referenced local file '${filePath}' caused an error:\n${e}`)
skip = true
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions test/preprocess.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,11 @@ describe('PlantUML preprocessing', () => {
expect(preprocessPlantUML(diagramTextWithStdLibIncludeFile, {})).to.be.equal(diagramTextWithStdLibIncludeFile)
})

it('should throw an error for unexisting local file referenced with "!include local-file-or-url"', () => {
it('should warn and return original diagramText for unexisting local file referenced with "!include local-file-or-url", because it can perhaps be found by kroki server', () => {
const diagramTextWithUnexistingLocalIncludeFile = `
!include ${localUnexistingFilePath}
alice -> bob`
const errorMessage = `Preprocessing of PlantUML include failed, because reading the referenced local file '${localUnexistingFilePath}' caused an error:
Error: ENOENT: no such file or directory, open '${localUnexistingFilePath}'`
expect(() => preprocessPlantUML(diagramTextWithUnexistingLocalIncludeFile, {})).to.throw(errorMessage)
expect(preprocessPlantUML(diagramTextWithUnexistingLocalIncludeFile, {})).to.be.equal(diagramTextWithUnexistingLocalIncludeFile)
})

it('should warn and return original diagramText for unexisting remote file referenced with "!include remote-url", because it can perhaps be found by kroki server', () => {
Expand Down

0 comments on commit fe014df

Please sign in to comment.