Skip to content

Commit 2bfc539

Browse files
Fixed PR comments
1 parent bd85841 commit 2bfc539

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

src/core/query-executor.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ContentstackClient, sanitizePath, log } from '@contentstack/cli-utilities';
1+
import { ContentstackClient, sanitizePath, log, formatError } from '@contentstack/cli-utilities';
22
import * as path from 'path';
33
import { QueryExportConfig, Modules } from '../types';
44
import { QueryParser } from '../utils/query-parser';
@@ -169,7 +169,7 @@ export class QueryExporter {
169169
fsUtil.writeFile(sanitizePath(contentTypesFilePath), contentTypes);
170170
log.success('Referenced content types export completed successfully', this.exportQueryConfig.context);
171171
} catch (error) {
172-
log.error(`Error exporting referenced content types: ${error.message}`, this.exportQueryConfig.context);
172+
log.error(`Error exporting referenced content types: ${formatError(error)}`, this.exportQueryConfig.context);
173173
throw error;
174174
}
175175
}
@@ -248,7 +248,7 @@ export class QueryExporter {
248248

249249
log.success('Dependent modules export completed successfully', this.exportQueryConfig.context);
250250
} catch (error) {
251-
log.error(`Error exporting dependent modules: ${error.message}`, this.exportQueryConfig.context);
251+
log.error(`Error exporting dependent modules: ${formatError(error)}`, this.exportQueryConfig.context);
252252
throw error;
253253
}
254254
}
@@ -268,7 +268,7 @@ export class QueryExporter {
268268

269269
log.success('Content modules export completed successfully', this.exportQueryConfig.context);
270270
} catch (error) {
271-
log.error(`Error exporting content modules: ${error.message}`, this.exportQueryConfig.context);
271+
log.error(`Error exporting content modules: ${formatError(error)}`, this.exportQueryConfig.context);
272272
throw error;
273273
}
274274
}
@@ -283,7 +283,7 @@ export class QueryExporter {
283283

284284
log.success('Entries export completed successfully', this.exportQueryConfig.context);
285285
} catch (error) {
286-
log.error(`Error exporting entries: ${error.message}`, this.exportQueryConfig.context);
286+
log.error(`Error exporting entries: ${formatError(error)}`, this.exportQueryConfig.context);
287287
throw error;
288288
}
289289
}
@@ -423,7 +423,7 @@ export class QueryExporter {
423423
log.info('No referenced assets found in entries', this.exportQueryConfig.context);
424424
}
425425
} catch (error) {
426-
log.error(`Error exporting referenced assets: ${error.message}`, this.exportQueryConfig.context);
426+
log.error(`Error exporting referenced assets: ${formatError(error)}`, this.exportQueryConfig.context);
427427
throw error;
428428
}
429429
}

src/utils/branch-helper.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import { getBranchFromAlias, log } from '@contentstack/cli-utilities';
2+
import { getBranchFromAlias, log, formatError } from '@contentstack/cli-utilities';
33
import { QueryExportConfig } from '../types';
44
import { createLogContext } from './logger';
55

@@ -29,8 +29,8 @@ export const setupBranches = async (config: QueryExportConfig, stackAPIClient: a
2929
const result = await stackAPIClient
3030
.branch(config.branchName)
3131
.fetch()
32-
.catch((err: Error): any => {
33-
log.error(`Error fetching branch: ${err.message}`, context);
32+
.catch((err: unknown): any => {
33+
log.error(`Error fetching branch: ${formatError(err)}`, context);
3434
return null;
3535
});
3636

@@ -63,7 +63,7 @@ export const setupBranches = async (config: QueryExportConfig, stackAPIClient: a
6363
}
6464
config.branchEnabled = true;
6565
} catch (error) {
66-
log.error(`Error setting up branches: ${error.message}`, context);
66+
log.error(`Error setting up branches: ${formatError(error)}`, context);
6767
throw error;
6868
}
6969
};

src/utils/dependency-resolver.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from 'path';
22
import { QueryExportConfig } from '../types';
33
import { fsUtil } from './index';
4-
import { ContentstackClient, sanitizePath, log } from '@contentstack/cli-utilities';
4+
import { ContentstackClient, sanitizePath, log, formatError } from '@contentstack/cli-utilities';
55

66
export class ContentTypeDependenciesHandler {
77
private exportQueryConfig: QueryExportConfig;
@@ -67,7 +67,7 @@ export class ContentTypeDependenciesHandler {
6767
this.exportQueryConfig.context,
6868
);
6969
} catch (error) {
70-
log.error(`Failed to separate extensions and Marketplace apps: ${error.message}`, this.exportQueryConfig.context);
70+
log.error(`Failed to separate extensions and Marketplace apps: ${formatError(error)}`, this.exportQueryConfig.context);
7171
// Keep original extensions if separation fails
7272
}
7373
} else {
@@ -125,7 +125,7 @@ export class ContentTypeDependenciesHandler {
125125

126126
return { extensions: regularExtensions, marketplaceApps };
127127
} catch (error) {
128-
log.error(`Failed to fetch extensions and Marketplace apps: ${error.message}`, this.exportQueryConfig.context);
128+
log.error(`Failed to fetch extensions and Marketplace apps: ${formatError(error)}`, this.exportQueryConfig.context);
129129
return { extensions: extensionUIDs, marketplaceApps: [] };
130130
}
131131
}

src/utils/query-parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from 'fs';
2-
import { CLIError } from '@contentstack/cli-utilities';
2+
import { CLIError, formatError } from '@contentstack/cli-utilities';
33
import { QueryExportConfig } from '../types';
44

55
export class QueryParser {
@@ -28,15 +28,15 @@ 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 the query file: ${error.message}`);
31+
throw new CLIError(`Failed to parse the query file: ${formatError(error)}`);
3232
}
3333
}
3434

3535
private parseFromString(queryString: string): any {
3636
try {
3737
return JSON.parse(queryString);
3838
} catch (error) {
39-
throw new CLIError(`Invalid JSON query: ${error.message}`);
39+
throw new CLIError(`Invalid JSON query: ${formatError(error)}`);
4040
}
4141
}
4242

src/utils/referenced-asset-handler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as path from 'path';
22
import * as fs from 'fs';
33
import { QueryExportConfig } from '../types';
44
import { fsUtil } from './index';
5-
import { sanitizePath, log } from '@contentstack/cli-utilities';
5+
import { sanitizePath, log, formatError } from '@contentstack/cli-utilities';
66

77
export class AssetReferenceHandler {
88
private exportQueryConfig: QueryExportConfig;
@@ -50,8 +50,8 @@ export class AssetReferenceHandler {
5050

5151
return result;
5252
} catch (error) {
53-
log.error(`Failed to extract assets: ${error.message}`, this.exportQueryConfig.context);
54-
return [];
53+
log.error(`Failed to extract assets: ${formatError(error)}`, this.exportQueryConfig.context);
54+
throw error;
5555
}
5656
}
5757

@@ -86,7 +86,7 @@ export class AssetReferenceHandler {
8686

8787
return entriesCount;
8888
} catch (error) {
89-
log.warn(`Failed to process file ${filePath}: ${error.message}`, this.exportQueryConfig.context);
89+
log.warn(`Failed to process file ${filePath}: ${formatError(error)}`, this.exportQueryConfig.context);
9090
return 0;
9191
}
9292
}
@@ -149,7 +149,7 @@ export class AssetReferenceHandler {
149149
}
150150
}
151151
} catch (error) {
152-
log.warn( `Failed to read directory ${dir}: ${error.message}`, this.exportQueryConfig.context);
152+
log.warn(`Failed to read directory ${dir}: ${formatError(error)}`, this.exportQueryConfig.context);
153153
}
154154

155155
return jsonFiles;

0 commit comments

Comments
 (0)