Improve error message

pull/132/head
David Finol 2021-06-30 19:25:08 -05:00
parent cf55f1c921
commit a5cfbb6607
4 changed files with 8 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,7 @@
import Input from './input';
jest.mock('./unity-version-parser');
describe('Input', () => {
describe('getFromUser', () => {
it('does not throw', () => {

View File

@ -17,7 +17,9 @@ class UnityVersionParser {
static read(projectPath) {
const filePath = path.join(projectPath, 'ProjectSettings', 'ProjectVersion.txt');
if (!fs.existsSync(filePath)) {
return 'auto';
throw new Error(
`Project settings file not found at "${filePath}". Have you correctly set the projectPath?`,
);
}
return UnityVersionParser.parse(fs.readFileSync(filePath, 'utf8'));
}

View File

@ -14,8 +14,8 @@ describe('UnityVersionParser', () => {
});
describe('read', () => {
it('does not throw', () => {
expect(() => UnityVersionParser.read('')).not.toThrow();
it('throws for invalid path', () => {
expect(() => UnityVersionParser.read('')).toThrow(Error);
});
it('reads from unity-project-with-correct-tests', () => {