Skip to content

Commit

Permalink
Merge pull request #250 from hashicorp/version-in-err
Browse files Browse the repository at this point in the history
feat: show requested version in error when none was matched
  • Loading branch information
ansgarm committed Apr 12, 2024
2 parents 90d6372 + 60b723c commit 2f9a50b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('getRelease', () => {
}));

const version = '1.2.7';
await expect(getRelease(name, version)).rejects.toThrow('No matching version found');
await expect(getRelease(name, version)).rejects.toThrow('No matching version found for constraint "1.2.7"');
});

it('should filter invalid versions', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,6 @@ function matchVersion(versions: Record<string, ResponseVersion>, range: string,
if (version) {
return new Release(versions[version]);
} else {
throw new Error('No matching version found');
throw new Error(`No matching version found for constraint "${range}"`);
}
}

0 comments on commit 2f9a50b

Please sign in to comment.