Skip to content

Commit dc2ea31

Browse files
committed
chore: Add more declarative CLI error logging
1 parent 1dfc90a commit dc2ea31

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

server/cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const handleAction = async (syncType, skipConfirm, configType, partials) => {
178178
}));
179179
console.log(`${chalk.green.bold('[success]')} Finished import`);
180180
} catch (e) {
181-
console.log(`${chalk.red.bold('[error]')} Something went wrong during the import. ${e}`);
181+
console.log(`${chalk.red.bold('[error]')} ${e}`);
182182
}
183183
}
184184
if (syncType === 'export') {
@@ -190,7 +190,7 @@ const handleAction = async (syncType, skipConfirm, configType, partials) => {
190190
}));
191191
console.log(`${chalk.green.bold('[success]')} Finished export`);
192192
} catch (e) {
193-
console.log(`${chalk.red.bold('[error]')} Something went wrong during the export. ${e}`);
193+
console.log(`${chalk.red.bold('[error]')} ${e}`);
194194
}
195195
}
196196
}

server/services/main.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,9 @@ module.exports = () => ({
227227

228228
try {
229229
await strapi.plugin('config-sync').types[type].importSingle(name, fileContents);
230-
if (onSuccess) {
231-
onSuccess(`${type}.${name}`);
232-
}
230+
if (onSuccess) onSuccess(`${type}.${name}`);
233231
} catch (e) {
234-
throw new Error(e);
232+
throw new Error(`Error when trying to import ${type}.${name}. ${e}`);
235233
}
236234
},
237235

@@ -240,6 +238,7 @@ module.exports = () => ({
240238
*
241239
* @param {string} configName - The name of the config file.
242240
* @param {object} onSuccess - Success callback to run on each single successfull import.
241+
*
243242
* @returns {void}
244243
*/
245244
exportSingleConfig: async (configName, onSuccess) => {
@@ -252,11 +251,9 @@ module.exports = () => ({
252251

253252
try {
254253
await strapi.plugin('config-sync').types[type].exportSingle(configName);
255-
if (onSuccess) {
256-
onSuccess(`${type}.${name}`);
257-
}
254+
if (onSuccess) onSuccess(`${type}.${name}`);
258255
} catch (e) {
259-
throw new Error(e);
256+
throw new Error(`Error when trying to export ${type}.${name}. ${e}`);
260257
}
261258
},
262259

0 commit comments

Comments
 (0)