Skip to content

Commit fe60dd3

Browse files
committed
improve error messages
1 parent 2c7dee8 commit fe60dd3

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

src/utils/branch-helper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { log } from './logger';
1212
*/
1313
export const setupBranches = async (config: QueryExportConfig, stackAPIClient: any): Promise<void> => {
1414
if (typeof config !== 'object') {
15-
throw new Error('Invalid config to setup the branch');
15+
throw new Error('The branch configuration is invalid.');
1616
}
1717

1818
try {
@@ -35,7 +35,7 @@ export const setupBranches = async (config: QueryExportConfig, stackAPIClient: a
3535
if (result && typeof result === 'object') {
3636
log(config, `Branch '${config.branchName}' found`, 'success');
3737
} else {
38-
throw new Error(`No branch found with the name '${config.branchName}'`);
38+
throw new Error(`No branch found named ${config.branchName}.`);
3939
}
4040
} else {
4141
// If no branch name provided, check if the stack has branches

src/utils/config-handler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ export async function setupQueryExportConfig(flags: any): Promise<QueryExportCon
3838
exportQueryConfig.managementToken = token;
3939
exportQueryConfig.stackApiKey = apiKey;
4040
if (!exportQueryConfig.managementToken) {
41-
throw new Error(`No management token found on given alias ${flags.alias}`);
41+
throw new Error(`No management token found for alias ${flags.alias}.`);
4242
}
4343
}
4444

4545
if (!exportQueryConfig.managementToken) {
4646
if (!isAuthenticated()) {
47-
throw new Error('Please login or provide an alias for the management token');
47+
throw new Error('Log in or provide an alias for the management token.');
4848
} else {
4949
exportQueryConfig.stackApiKey = flags['stack-api-key'] || (await askAPIKey());
5050
if (typeof exportQueryConfig.stackApiKey !== 'string') {
51-
throw new Error('Invalid API key received');
51+
throw new Error('The API key is invalid.');
5252
}
5353
}
5454
}

src/utils/dependency-resolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class ContentTypeDependenciesHandler {
7070
'info',
7171
);
7272
} catch (error) {
73-
log(this.exportQueryConfig, `Error separating extensions and marketplace apps: ${error.message}`, 'error');
73+
log(this.exportQueryConfig, `Failed to separate extensions and Marketplace apps: ${error.message}`, 'error');
7474
// Keep original extensions if separation fails
7575
}
7676
} else {
@@ -131,7 +131,7 @@ export class ContentTypeDependenciesHandler {
131131

132132
return { extensions: regularExtensions, marketplaceApps };
133133
} catch (error) {
134-
log(this.exportQueryConfig, `Error fetching extensions and marketplace apps: ${error.message}`, 'error');
134+
log(this.exportQueryConfig, `Failed to fetch extensions and Marketplace apps: ${error.message}`, 'error');
135135
return { extensions: extensionUIDs, marketplaceApps: [] };
136136
}
137137
}

src/utils/query-parser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class QueryParser {
2828
const content = fs.readFileSync(filePath, 'utf-8');
2929
return JSON.parse(content);
3030
} catch (error) {
31-
throw new CLIError(`Failed to parse query file: ${error.message}`);
31+
throw new CLIError(`Failed to parse the query file: ${error.message}`);
3232
}
3333
}
3434

@@ -42,16 +42,16 @@ export class QueryParser {
4242

4343
private validate(query: any): void {
4444
if (!query || typeof query !== 'object') {
45-
throw new CLIError('Query must be a valid JSON object');
45+
throw new CLIError('The query must be a valid JSON object.');
4646
}
4747

4848
if (!query.modules || typeof query.modules !== 'object') {
49-
throw new CLIError('Query must contain a "modules" object');
49+
throw new CLIError('The query must contain a "modules" object.');
5050
}
5151

5252
const modules = Object.keys(query.modules);
5353
if (modules.length === 0) {
54-
throw new CLIError('Query must contain at least one module');
54+
throw new CLIError('The query must contain at least one module.');
5555
}
5656

5757
// Validate supported modules

src/utils/referenced-asset-handler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class AssetReferenceHandler {
5252

5353
return result;
5454
} catch (error) {
55-
log(this.exportQueryConfig, `Error extracting assets: ${error.message}`, 'error');
55+
log(this.exportQueryConfig, `Failed to extract assets: ${error.message}`, 'error');
5656
return [];
5757
}
5858
}
@@ -89,7 +89,7 @@ export class AssetReferenceHandler {
8989

9090
return entriesCount;
9191
} catch (error) {
92-
log(this.exportQueryConfig, `Error processing file ${filePath}: ${error.message}`, 'warn');
92+
log(this.exportQueryConfig, `Failed to process file ${filePath}: ${error.message}`, 'warn');
9393
return 0;
9494
}
9595
}
@@ -152,7 +152,7 @@ export class AssetReferenceHandler {
152152
}
153153
}
154154
} catch (error) {
155-
log(this.exportQueryConfig, `Error reading directory ${dir}: ${error.message}`, 'warn');
155+
log(this.exportQueryConfig, `Failed to read directory ${dir}: ${error.message}`, 'warn');
156156
}
157157

158158
return jsonFiles;

0 commit comments

Comments
 (0)