Skip to content

Commit

Permalink
Improve error message when file path cannot be resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
georg-schwarz committed May 21, 2024
1 parent ad744b7 commit 63c607b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ describe('Validation of ImportDefinition', () => {
expect(validationAcceptorMock).toHaveBeenNthCalledWith(
1,
'error',
'Import cannot be resolved.',
'Import from "not-existing-imported-file-deeper.jv" could be resolved. Check if the file exists in the given location.',
expect.any(Object),
);
expect(validationAcceptorMock).toHaveBeenNthCalledWith(
2,
'error',
'Import cannot be resolved.',
'Import from "./not-existing-imported-file-deeper.jv" could be resolved. Check if the file exists in the given location.',
expect.any(Object),
);
});
Expand All @@ -121,13 +121,13 @@ describe('Validation of ImportDefinition', () => {
expect(validationAcceptorMock).toHaveBeenNthCalledWith(
1,
'error',
'Import cannot be resolved.',
'Import from "existing-imported-file.njv" could be resolved. Check if the file exists in the given location.',
expect.any(Object),
);
expect(validationAcceptorMock).toHaveBeenNthCalledWith(
2,
'error',
'Import cannot be resolved.',
'Import from "./existing-imported-file.njv" could be resolved. Check if the file exists in the given location.',
expect.any(Object),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ function checkPathExists(
): void {
const resolvedImport = props.importResolver.resolveImport(importDefinition);
if (resolvedImport === undefined) {
props.validationContext.accept('error', 'Import cannot be resolved.', {
node: importDefinition,
property: 'path',
});
props.validationContext.accept(
'error',
`Import from "${importDefinition.path}" could be resolved. Check if the file exists in the given location.`,
{
node: importDefinition,
property: 'path',
},
);
}
}

0 comments on commit 63c607b

Please sign in to comment.