Skip to content
Merged
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
31 changes: 28 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,38 +198,60 @@ async function main(): Promise<void> {
} catch (error) {
process.exitCode = 1;

if (!UNTRACKED_COMMANDS.includes(command)) {
segmentTrackEnd(command, { error });
if (error instanceof CommandError) {
if (!UNTRACKED_COMMANDS.includes(command)) {
segmentTrackEnd(command);
}
console.error(error.message);
return;
Comment thread
cursor[bot] marked this conversation as resolved.
}

if (error instanceof CommandError || error instanceof NoSupportedFrameworkError) {
if (error instanceof NoSupportedFrameworkError) {
if (!UNTRACKED_COMMANDS.includes(command)) {
segmentTrackEnd(command, { error });
}
console.error(error.message);
return;
}

if (error instanceof UnauthorizedRequestError || error instanceof ForbiddenRequestError) {
if (!UNTRACKED_COMMANDS.includes(command)) {
segmentTrackEnd(command, { error });
}
Comment thread
angeloashmore marked this conversation as resolved.
console.error("Not logged in. Run `prismic login` first.");
return;
}

if (error instanceof NotFoundRequestError) {
if (!UNTRACKED_COMMANDS.includes(command)) {
segmentTrackEnd(command);
}
console.error(
error.message || "Not found. Verify the repository and any specified identifiers exist.",
);
return;
}

if (error instanceof InvalidPrismicConfigError) {
if (!UNTRACKED_COMMANDS.includes(command)) {
segmentTrackEnd(command);
}
console.error(`${error.message} Run \`prismic init\` to re-create a config.`);
return;
}

if (error instanceof MissingPrismicConfigError) {
if (!UNTRACKED_COMMANDS.includes(command)) {
segmentTrackEnd(command);
}
console.error(`${error.message} Run \`prismic init\` to create a config.`);
return;
}

if (error instanceof TypeBuilderRequiredError) {
if (!UNTRACKED_COMMANDS.includes(command)) {
segmentTrackEnd(command);
}
console.error(dedent`
This command requires the Type Builder in your repository.

Expand All @@ -242,6 +264,9 @@ async function main(): Promise<void> {
return;
}

if (!UNTRACKED_COMMANDS.includes(command)) {
segmentTrackEnd(command, { error });
}
await sentryCaptureError(error);
throw error;
}
Expand Down