Skip to content
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
8 changes: 4 additions & 4 deletions src/commands/tsgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ export default class TypeScriptCodeGeneratorCommand extends Command {

if (token.type !== "delivery") {
this.warn(
"Possibly using a management token. You may not be able to connect to your Stack. Please use a delivery token.",
"You might be using a management token. Connection may fail. Use a delivery token instead.",
);
}

if (!outputPath || !outputPath.trim()) {
this.error("Please provide an output path.", { exit: 2 });
this.error("Output path is required.", { exit: 2 });
}

const config: StackConnectionConfig = {
Expand All @@ -160,7 +160,7 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
// Check if token has delivery type (required for GraphQL)
if (token.type !== "delivery") {
throw new Error(
"GraphQL API requires a delivery token. Management tokens are not supported for GraphQL operations.",
"GraphQL API requires a delivery token. Management tokens aren't supported.",
);
}

Expand All @@ -185,7 +185,7 @@ export default class TypeScriptCodeGeneratorCommand extends Command {
const result = await graphqlTS(graphqlConfig);

if (!result) {
throw new Error("GraphQL API returned no result");
throw new Error("No result returned by the GraphQL API.");
}

fs.writeFileSync(outputPath, result);
Expand Down
22 changes: 11 additions & 11 deletions src/lib/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,47 +39,47 @@ export const printFormattedError = (error: FormattedError, context: string) => {
return;
}

let errorMessage = "An unexpected error occurred";
let errorMessage = "An unexpected error occurred. Try again.";
let hint = "";

switch (errorCode) {
case "AUTHENTICATION_FAILED":
errorMessage = "Authentication failed";
errorMessage = "Authentication failed. Check your credentials and try again.";
hint = "Please check your API key, token, and region.";
break;
case "INVALID_CREDENTIALS":
errorMessage = "Invalid credentials provided";
errorMessage = "Invalid credentials. Please verify and re-enter your login details.";
hint = "Please verify your API key, token, and region.";
break;
case "INVALID_INTERFACE_NAME":
case "INVALID_CONTENT_TYPE_UID":
errorMessage = "TypeScript syntax error detected in the generated types.";
errorMessage = "Generated types contain a TypeScript syntax error.";
hint =
"Use a prefix to ensure all interface names are valid TypeScript identifiers.";
break;
case "INVALID_GLOBAL_FIELD_REFERENCE":
errorMessage = "TypeScript syntax error detected in the generated types.";
errorMessage = "Generated types contain a TypeScript syntax error.";
hint =
"Use a prefix to ensure all interface names are valid TypeScript identifiers.";
break;
case "VALIDATION_ERROR":
errorMessage = "TypeScript syntax error detected in generated types";
errorMessage = "Type generation failed due to a validation error.";
hint =
error?.error_message ||
"Validation error occurred during type generation";
"Type generation failed due to a validation error.";
break;
case "TYPE_GENERATION_FAILED":
errorMessage = "Type generation failed due to an internal error";
errorMessage = "Type generation failed due to a system error. Try again.";
hint =
error?.error_message ||
"An unexpected error occurred during type generation";
"Unexpected error during type generation. Try again.";
break;
default:
errorMessage =
error?.error_message ||
error?.message ||
"An unexpected error occurred";
hint = "Please check the error details and try again.";
"An unexpected error occurred. Try again.";
hint = "Check the error details and try again.";
}

// Print formatted error output
Expand Down