Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: better error when package is not found #5213

Merged
merged 1 commit into from
Jan 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/package-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,18 @@ export default class PackageRequest {

const Resolver = this.getRegistryResolver();
const resolver = new Resolver(this, name, range);
return resolver.resolve();
try {
return await resolver.resolve();
} catch (err) {
// if it is not an error thrown by yarn and it has a parent request,
// thow a more readable error
if (!(err instanceof MessageError) && this.parentRequest && this.parentRequest.pattern) {
throw new MessageError(
this.reporter.lang('requiredPackageNotFoundRegistry', pattern, this.parentRequest.pattern, this.registry),
);
}
throw err;
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/reporters/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const messages = {
invalidVersion: 'Invalid version supplied.',
requiredVersionInRange: 'Required version in range.',
packageNotFoundRegistry: "Couldn't find package $0 on the $1 registry.",
requiredPackageNotFoundRegistry: "Couldn't find package $0 required by $1 on the $2 registry.",
doesntExist: "Package $1 refers to a non-existing file '$0'.",
missingRequiredPackageKey: `Package $0 doesn't have a $1.`,
invalidAccess: 'Invalid argument for access, expected public or restricted.',
Expand Down